-
Notifications
You must be signed in to change notification settings - Fork 27.4k
ng-reset #2726
Comments
As part of our effort to clean out old issues, this issue is being automatically closed since it has been inactivite for over two months. Please try the newest versions of Angular ( Thanks! |
Would this approach work? http://jsfiddle.net/GlobalDomestic/GjPwK/5 Of course this is a bit of a hack since I can't access the ng-form directive controls array directly (without an actual PR). One issue is storing initial model values as the digest loop needs time to stabilize the model values. Using $timeout for this seems clumsy to me. Another thought was if someone applied model values after the form was created. Should that be supported as the default value? If so, how should that be conveyed? Thoughts? |
Nice! Capturing 'initial state' - Yes, calling $timeout with (implicit) 0 delay might be an issue - if someobody:
Ad 2) is a bad practice.. |
reacting to $$postDigest event is another way of capturing the 'initial state' |
@btford Any thoughts on this? Just wondering if it's worth any continued effort. |
I like the idea of forms accepting ng-reset attribute analogous to ng-submit, and I think this issue should be reopened. Right now, reset buttons clear the fields while leaving the model intact (rather not desired behavior), and if I want to prevent this (and add my own logic for resetting form), I need to use $event.preventDefault in button's ng-click. I think it would be much cleaner if I could do it in form's ng-reset instead. @JasonCust Your ng-reset is not very consistent with ng-submit. What if I wanted to supply my own logic for resetting the form? I'd much more like ng-reset to be a place for doing it myself, rather than a switch for some automagic functionality. |
If there is ng-submit directive, is there any specific reason that there is no ng-reset directive?
The text was updated successfully, but these errors were encountered: