AngularJS ng-model-options
Directive
Example
Bind the input field value to the scope variable on blur:
<div ng-app="myApp" ng-controller="myCtrl"> <input ng-model="name"
ng-model-options="{updateOn: 'blur'}">
</div><script>var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) { $scope.name
= "John Doe";});</script>
Definition and Usage
The ng-model-options directive binds HTML form elements to scope variables.
You can specify when the data binding should trigger, or specify a wait time in milliseconds. The parameter settings can be referred to as follows.
Syntax
<input>, <select>, <textarea> elements support this directive.
Parameter Values
Value | Description | ||
---|---|---|---|
option | Specifies the rules for data binding, as follows: <br> <br>{updateOn: 'event'} specifies data binding after the event occurs <br> <br>{debounce : 1000} <br>Specifies the wait time in milliseconds before data binding <br> <br>{allowInvalid <br> : true | false} Specifies whether data binding should occur after validation <br> <br>{getterSetter : true | false} Specifies whether to bind as getters/setters to the model <br> <br>{timezone : '0100'} <br> Specifies whether to use timezones |