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
.
<input ng-model-instant> ... </input>
<input class="ng-model-instant"> ... </input>
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'); });