2015-07-21 62 views

回答

2

Angular 1.3在ng-model中引入了debounce選項,它完全符合您的需求 - 延遲模型中的更改。

<div ng-controller="ExampleController"> 
    <form name="userForm"> 
    <label>Name: 
     <input type="text" name="userName" 
      ng-model="user.name" 
      ng-model-options="{ debounce: 1000 }" /> 
    </label> 
    <button ng-click="userForm.userName.$rollbackViewValue(); user.name=''">Clear</button> 
    <br /> 
    </form> 
    <pre>user.name = <span ng-bind="user.name"></span></pre> 
</div> 

https://docs.angularjs.org/api/ng/directive/ngModelOptions

如需進一步信息,請在這裏討論How to put a delay on AngularJS instant search?

一個戰利品