Reputation: 67
I have a search button in Angularjs application, when i click search button that will render different widgets each widget have <form>
that submit data to the server if any one form validation fails and the state of the form is $dirty. if I search again with different values and wants to clear the previous errors.
How can i reset all the forms to $pristine on clicking search button again?
Upvotes: 1
Views: 574
Reputation:
you can use $scope.formName.$setPristine(true)
. This is available in later versions of angular and is used to reset the forms to pristine state
Upvotes: 1