3

I am using angular.js version 1.1.5 which has $setPristine on the form controller. But this method does not seem to clear any errors associated with fields. The code below works for me, but I am not sure whether this is the right way to clear errors. Any advice?

In my controller:

if ($scope.myform) {
    $scope.myform.$setPristine();
    delete $scope.myform.myfield.$error.myvalidator;
}
akonsu
  • 28,824
  • 33
  • 119
  • 194

1 Answers1

6

The $setPristine() clears only the flag dirty in a form but the validation in a form are cleared with $setValidity()

massintha
  • 214
  • 1
  • 3
  • an example: http://stackoverflow.com/questions/14363656/using-setvalidity-inside-a-controller – chovy Feb 12 '15 at 05:21