angular/angular.js — pull request #4066 by lastnico (2013-09-20 13:53:56+00:00)
Title: Add a $setDirty() method to NgModelController

As it was done for FormController.$setPristine, I would like to propose to add the $setDirty() method on NgModelController.

There is one concrete case where this is useful: Suppose you have a form with different inputs, some being required/minlength/pattern-based/... If the user clicks the Submit button, he won't see which inputs are actually invalid.

See example:
http://jsfiddle.net/lastnico/P6gh5/

Note that the CSS is designed on purpose to only mark .ng-dirty.ng-invalid inputs as red, just to not scare the user immediately with tons of red things while he did not even click anything.

By having a way to do a $setDirty() programmatically on each NgModelController, we will give the user a feedback on what's wrong (An even better solution would be to have a FormController.$setDirty() function that would notify deeper elements instead of going up in its hierarchy (as it currently does)).