You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 1, 2020. It is now read-only.
Repository navigation
This repository was archived by the owner on Jul 1, 2020. It is now read-only.
I'm trying to reset form to it's pristine state, but cannot succeed. I looked for a working example here, but couldn't find that either. I am changing all the input values to empty text (""), and then calling myform.$setPristine(); I think that is the way to do it. But the $setPrisitine() doesn't seem to do anything.
Can anyone guide me where to check or what could be the issue?
Hello, yes I use the $touched especially for showing errors on an empty form. For example, looking at this functionality on the Wiki - Pre-Validate Form on Page Load is done using the $touched as you found out.
I could had a comment in the Wiki documentation if you want, but yes that is the correct way of resetting a form.
Added a Wiki - Reset Form, that should explain it well. Let me know if you have other comments about it. :)
Actually I did not try it, but does it reset the $touched on each input element as well? I hope it does, else I will have to make another function in the Service.
Ok I tried it and that is actually not enough, doing the $setUntouched() and $setPristine() does not remove the errors displayed (if any).
I will re-open this issue and add a new function in the Service, should be done in the next couple days. Since I also add Protractor tests, it's a bit longer to do both.
This functionality was added in v1.3.31, there is a lot more options than I imagined at first. So the possible options you can pass the function should cover all cases.
Make sure to update to latest v1.3.31 to see the changes
Enjoy ;)
@ghiscoding, thank you for taking time to take a look at this issue. I will try the new version when I'll have time. If anything comes up, will report back here. Thanks again! :)
Activity
iltera commentedon Jun 15, 2015
Added $setUntounched() and I guess it works now :)
ghiscoding commentedon Jun 15, 2015
Hello, yes I use the
$touchedespecially for showing errors on an empty form. For example, looking at this functionality on the Wiki - Pre-Validate Form on Page Load is done using the$touchedas you found out.I could had a comment in the Wiki documentation if you want, but yes that is the correct way of resetting a form.
Thanks for using it ;)
ghiscoding commentedon Jun 15, 2015
Added a Wiki - Reset Form, that should explain it well. Let me know if you have other comments about it. :)
Actually I did not try it, but does it reset the
$touchedon each input element as well? I hope it does, else I will have to make another function in the Service.ghiscoding commentedon Jun 16, 2015
Ok I tried it and that is actually not enough, doing the
$setUntouched()and$setPristine()does not remove the errors displayed (if any).I will re-open this issue and add a new function in the Service, should be done in the next couple days. Since I also add Protractor tests, it's a bit longer to do both.
Thanks for the feedback
Enhancement #39 - How to Reset a Form
ghiscoding commentedon Jun 21, 2015
This functionality was added in v1.3.31, there is a lot more options than I imagined at first. So the possible options you can pass the function should cover all cases.
Make sure to update to latest v1.3.31 to see the changes
Enjoy ;)
iltera commentedon Jun 23, 2015
@ghiscoding, thank you for taking time to take a look at this issue. I will try the new version when I'll have time. If anything comes up, will report back here. Thanks again! :)