Input is an HTML tag which is used to get user input.ng-model is an angular directive which is used for data binding(i.e.,reference to the input element is provided by the ng-model). These both are combined to modify the input field.
The following states are established to the input field whose value is true for the following.
- $untouched: when the field has not been touched
- $touched: when the field has been touched
- $pristine: when the field has not been modified
- $dirty: when the field has been modified
- $invalid: when the field content is not valid
- $valid: when the field content is valid
Example: $valid state for the required input field in a form is explained below
For the above-mentioned input directive, few CSS classes are added. They are:
- ng-untouched: The field has not been touched yet
- ng-touched: The field has been touched
- ng-pristine: The field has not been modified yet
- ng-dirty: The field has been modified
- ng-valid: The field content is valid
- ng-invalid: The field content is not valid
- ng-valid-key: One key for each validation.
- ng-invalid-key: One key for each validation.
The classes are removed if the value is false.
If the input field is used along with the required attribute, valid (when there is an input it is set to true) and invalid (when there is no input it is set to true) states are established. The classes are removed if the value is false.
- AngularJS | ng-jq Directive
- AngularJS | ng-value Directive
- AngularJS | ng-src Directive
- AngularJS | ng-cut Directive
- AngularJS | ng-if Directive
- AngularJS | Directive
- AngularJS | ng-csp Directive
- AngularJS | ng-app Directive
- AngularJS | ng-readonly Directive
- AngularJS | ng-submit Directive
- AngularJS | ng-style Directive
- AngularJS | ng-switch Directive
- AngularJS | ng-srcset Directive
- AngularJS | ng-selected Directive
- AngularJS | ng-include Directive
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.