ngModelDirective = function() {
  return {
    require: ['ngModel', '^?form'],
    controller: NgModelController,
    link: function(scope, element, attr, ctrls) {
      // notify others, especially parent forms

      var modelCtrl = ctrls[0],
          formCtrl = ctrls[1] || nullFormCtrl;

      formCtrl.$addControl(modelCtrl);

      element.bind('$destroy', function() {
        formCtrl.$removeControl(modelCtrl);
      });
    }
  };
}
@ngdoc directive
@name ng.directive:ngModel

@element input

@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 {@link ng.directive:form form}.

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

 - {@link ng.directive:input input}
   - {@link ng.directive:input.text text}
   - {@link ng.directive:input.checkbox checkbox}
   - {@link ng.directive:input.radio radio}
   - {@link ng.directive:input.number number}
   - {@link ng.directive:input.email email}
   - {@link ng.directive:input.url url}
 - {@link ng.directive:select select}
 - {@link ng.directive:textarea textarea}