# `ngModel` (directive in module `ng` )

Improve this doc

## Description

Is directive that tells Angular to do two-way data binding. It works together with `input`, `select`, `textarea`. You can easily write your own directives to use `ngModel` as well.

`ngModel` is responsible for:

- binding the view into the model, which other directives such as `input`, `textarea` or `select` require,
- providing validation behavior (i.e. required, number, email, url),
- keeping state of the control (valid/invalid, dirty/pristine, validation errors),
- setting related css class onto the element (`ng-valid`, `ng-invalid`, `ng-dirty`, `ng-pristine`),
- register the control with parent `form`.

For basic examples, how to use `ngModel`, see:

- `input`
  - `text`
  - `checkbox`
  - `radio`
  - `number`
  - `email`
  - `url`
- `select`
- `textarea`

## Usage

as attribute

    <input ng-model>
       ...
    </input>

as class

    <input class="ng-model">
       ...
    </input>