Resetting form after submit in Angularjs

angularjs, angularjs-directive, javascript

Solution

You can reset a form by, `$scope.formName.$setPristine();` but if you're binding a model object to your inputs, you need to take care of clearing those too, ie:

`$scope.currentRecord={};`

EDIT

As ToodoN-Mike pointed out, don't forget to set

`$scope.formName.$setUntouched()`

The `$touched` flag was introduced in angular 1.3.

Problem

Hi I have a form which does update on button click. ``` $scope.action = "Update"; var id = $routeParams.editId; scope.item = updateRecord.get({ id: id }); ``` Once the item is updated it doesn't remove the entered information in the form fields. I was wondering what is available in angularjs to add in the above code after udpating so that it also clears to form. Thanks

Original source

Related problems