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);

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

@element input

@description
The `ngModel` directive binds an `input`,`select`, `textarea` (or custom form control) to a
property on the scope using {@link ng.directive:ngModel.NgModelController NgModelController},
which is created and exposed by this directive.

`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 the state of the control (valid/invalid, dirty/pristine, validation errors).
- Setting related css classes on the element (`ng-valid`, `ng-invalid`, `ng-dirty`, `ng-pristine`).
- Registering the control with its parent {@link ng.directive:form form}.

Note: `ngModel` will try to bind to the property given by evaluating the expression on the
current scope. If the property doesn't already exist on this scope, it will be created
implicitly and added to the scope.

For best practices on using `ngModel`, see:

 - {@link https://github.com/angular/angular.js/wiki/Understanding-Scopes}

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}