It seems as if $setPristine is not supported in ionic-angular. Am I missing something? If it’s not supported is there an alternative method for clearing forms?
Can you post a CodePen sample of that not working? It’s hard to say without seeing it.
I’m discovering the same issue as choiway…
Here’s my codepen http://codepen.io/anon/pen/ogtKf
There is no error since I’m using $parent.contactForm for my formname, but the form will not get cleared after submitting it… don’t know what to do anymore oO! I also tried setting all inputs of the form to $prestine = true, still no better result.
Thanks for your help!
This will error when trying to call .setPristine() as you might traditionally in angular - $scope.formname.$setPristine().
As a workaround you can explicitly pass the form as a parameter through to the controller you can call $setPristine() on it. This perhaps isn’t ideal.
It’s to do with scopes - the form is inside the ion-content directive which will create it’s own scope (I believe?!). So I guess you could find the form by navigating child scopes (depending on how you’ve defined your page and controller). Or you can put the ng-controller attribute directly on the form element then you’ll be able to call setPristine on the scope from within your controller - like this:
Has this been resolved? I am trying to set a form to pristine and $scope.formName.$setPristine is not working.
$setPristine does not work with Ionic. I am submitting a form, but if the user comes back to the form, it is not resetting the pristine state.
How can we set a form back to $pristine?
Any help with this? What version of Angular does Ionic 1.2.1 use? I think $setPristine was not available until Angular 1.1.x.