THE WORLD'S LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

AngularJS ng-model-options Directive


Example

Wait with the data-binding until the field loses focus:

<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>
Try it yourself »

Definition and Usage

The ng-model-options directive is used to control the binding of an HTML form element and a variable in the scope.

You can specify that the binding should wait for a specific event to occur, or wait a specific number of milliseconds, and more, see the legal values listed in the parameter values below.


Syntax

<element ng-model-options="option"></element>

Supported by <input>, <select>, and <textarea> elements.


Parameter Values

Value Description
option An object specifying what options the data-binding must follow. Legal objects are:

{updateOn: 'event'} specifies that the binding should happen when the specific event occur.

{debounce : 1000} specifies how many milliseconds to wait with the binding.

{allowInvalid : true|false} specify if the binding can happen if the value did not validate.

{getterSetter : true|false} specifies if functions bound to the model should be treated as getters/setters.

{timezone : '0100'} Specifies what timezone should be used when working with the Date object.