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;
}
The $setPristine() clears only the flag dirty in a form but the validation in a form are cleared with $setValidity()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With