最新的Web開發教程
 

AngularJS NG-模式選項指令


具有約束力的數據,直到字段失去焦點等待:

<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.