J. Davidson J. Davidson - 1 year ago 91
Javascript Question

Resetting form after submit in Angularjs

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.

Answer Source

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: