AngularJS

AngularJS Directives

AngularJS Filters and Elements

AngularJS Tutorials

AngularJS input Directive

AngularJS input Directive

 

 

AngularJS is used to change the default behavior of input elements by using an ng-model attribute. It provides data-binding as it becomes part of the AngularJS model and can be updated by AngularJS. Moreover, we can validate it and it has a $valid state. We can also do state control by it.

 

Input fields states are:-

 

  1. $untouched - The field has not been touched yet
  2. $touched - The field has been touched
  3. $pristine - The field has not been modified yet
  4. $dirty - The field has been modified
  5. $invalid - The field content is not valid
  6. $valid - The field content is valid

All of these states above have boolean values i.e, true or false.

We can change the style of each state by using the built-in CSS classes of the given states.

 

Form classes are:-

 

  1. ng-untouched - The field has not been touched yet
  2. ng-touched - The field has been touched
  3. ng-pristine - The field has not been  modified yet
  4. ng-dirty - The field has been modified
  5. ng-valid - The field content is valid
  6. ng-invalid - The field content is not valid
  7. ng-valid-key - One key for each validation. Example: ng-valid-readonly.
  8. ng-invalid-key - Example: ng-invalid-required

 

Syntax:-

 

< input ng-model="name" >

Code Explanation

All Tutorials related to AngularJS Filters and Elements

All Sections related to AngularJS