AngularJS ng-model-options지시문


예시

필드가 포커스를 잃을 때까지 데이터 바인딩을 기다립니다.

<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>, <select> 및 <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.