Visual Cues for Users
HTML5 provides :invalid
and :valid
pseudo-selectors for its input fields.
Unfortunately, this system is rather unsophisticated and would require more manual effort in order to work with complex forms or user behavior.
Rather than writing extra code, and creating and enforcing your own CSS classes, to manage these behaviors, Angular provides you with several classes, already accessible on your inputs.
Note the three pairs:
valid / invalid
untouched / touched
pristine / dirty
These pairs can be used in many combinations in your CSS to change style based on the three separate flags they represent. Angular will toggle between the pairs on each input as the state of the input changes.
.ng-untouched
will not be replaced by.ng-touched
until the user leaves the input for the first time
For templating purposes, Angular also gives you access to the unprefixed properties on the input, in both code and template:
Last updated