javascriptangularjs

AngularJS - difference between pristine/dirty and touched/untouched


AngularJS Developer Guide - Forms lists many styles and directives regarding forms and fields. For each one, a CSS class:

ng-valid
ng-invalid
ng-pristine
ng-dirty
ng-touched
ng-untouched

What's the difference between pristine/dirty, and touched/untouched?


Solution

  • AngularJS Developer Guide - CSS classes used by AngularJS

    • @property {boolean} $untouched True if control has not lost focus yet.
    • @property {boolean} $touched True if control has lost focus.
    • @property {boolean} $pristine True if user has not interacted with the control yet.
    • @property {boolean} $dirty True if user has already interacted with the control.