AngularJS - Reset form using $setPristine() when all controls are emptied

635 views
Skip to first unread message

mark macneil

unread,
Jul 10, 2013, 10:29:37 AM7/10/13
to ang...@googlegroups.com

I'm trying to create a reusable directive that will simply reset my form and it's child controls to pristine using the $setPristine() method IF all the form's <input type="text"> controls are emptied after the user has previously interacted with them and marked them dirty.

So basically the directive would monitor all the form <input type="text"> elements and if it determines all elements are empty call $setPristine() to reset everything back to square one.

This seems kind of trivial and something I could bust out with jQuery in 5 mins but I'm just getting my feet wet with Angular and I've been stumbling around this for a couple of hours struggling with the best approach so any help or guidance is greatly appreciated!


Thanks!!

Reply all
Reply to author
Forward
0 new messages