The ngModel directive in AngularJS binds an input, select, textarea (or custom form control) to a property on the scope using NgModelController, which is created and exposed by this directive.
ngModel is responsible for:
- Instantiating the ngModelController
- Binding the view into the model, which other directives such as
input,textareaorselectrequire. - Providing validation behavior (i.e. required, number, email, url).
- Keeping the state of the control (valid/invalid, dirty/pristine, touched/untouched, validation errors).
- Setting related CSS classes on the element (
ng-valid,ng-invalid,ng-dirty,ng-pristine,ng-touched,ng-untouched) including animations. - Registering the control with its parent form.
- Formatters, Parsers and View change listeners
Information from AngularJS API
See also