例
具有约束力的数据,直到字段失去焦点等待:
<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>
试一试» 定义和用法
在ng-model-options
指令用于控制HTML表单元素和范围的变量绑定。
您可以指定绑定应该等待发生特定事件,或等待毫秒的具体数量,更多的,请参阅下面的参数值列出的合法值。
句法
< element ng-model-options=" option "></ element >
通过的<input>的支持下,<选择>和<textarea>的元素。
参数值
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. |