Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

removing field errors when setting form to pristine state

Tags:

angularjs

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;
}
like image 217
akonsu Avatar asked Dec 09 '25 10:12

akonsu


1 Answers

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

like image 192
massintha Avatar answered Dec 12 '25 04:12

massintha



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!