Rajesh GK
Rajesh GK

Reputation: 67

Angularjs reset all forms in a page to pristine state

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

Answers (1)

user6145052
user6145052

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

Related Questions