angular.module.ng.$compileProvider.directive.ng-model-instant

Description

By default, Angular udpates the model only on blur event - when the input looses focus. If you want to update after every key stroke, use ng-model-instant.

Usage

as attribute
<input ng-model-instant>
   ...
</input>
as class
<input class="ng-model-instant">
   ...
</input>

Example

  First name: <input type="text" ng-model="firstName" /><br />
  Last name: <input type="text" ng-model="lastName" ng-model-instant /><br />

  First name ({{firstName}}) is only updated on `blur` event, but the last name ({{lastName}})
  is updated immediately, because of using `ng-model-instant`.
  it('should update first name on blur', function() {
    input('firstName').enter('santa', 'blur');
    expect(binding('firstName')).toEqual('santa');
  });

  it('should update last name immediately', function() {
    input('lastName').enter('santa', 'keydown');
    expect(binding('lastName')).toEqual('santa');
  });