-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Form does not revert to initial state when submitted #1903
Comments
You can workaround it by giving a name to the form and input and setting:
|
Hey, I have the same problem, |
@andreabadesso the named property is based on the |
I updated the code pen giving a name to the form and to the input and indeed setting http://codepen.io/anon/pen/ogaROy Also for some reason setting |
Adding a little context: By default, If you want to reset the whole form (i.e. all
|
I think something like this should be added to one of our demos. |
I have added $scope..$setPristine(); & $scope..$setUntouched(); So the input element has ng-pristine & ng-untouched. But has a ng-invalid-required! As a work around I am using |
Using @andreabadesso's workaround, I'm able to clear errors after resetting the values in the form. However, I think calling Anyway, thanks for the workaround, @andreabadesso. |
Some I tried in the console to play with either the form or the input and I don't have time to dig more into this but that's annoying.
|
form.$setUntouched() is works for input field's border but not for ng-messages:
|
Can we re-open this, its still broken in 1.1.1 |
I also still have this problem. |
you most likely didn't import 'angular-messages' module. i was also having the same issue, but just adding that fixed everything. have a look at this https://scotch.io/tutorials/angularjs-form-validation-with-ngmessages. i know it's pure angular, but it works the same, no need to check $touched or any other sorcery. |
This issue is closed as it falls in the 'deprecated' category. We deprecate issues for one or more of the following reasons:
|
When I submit a form that I want to re-use and reset the inputs I expect 'ng-invalid-required' to no longer be set on the form. Instead it is still set and the form is shown as "red".
Here's a small screencast showing the problem:
Here's a code pen:
http://codepen.io/anon/pen/ogaROy
I'm resetting the form by resetting the model:
However I've also tried
$setPristine()
and that didn't help either. Is there something I'm missing or is this a bug?This issue is potentially related: #931
The text was updated successfully, but these errors were encountered: