Reputation: 162
I want to write a code that gives the results after some delay of user search instead of instantaneous result. Can I do that using a filter?
Upvotes: 0
Views: 85
Reputation: 1915
Angular 1.3 introduces debounce
options in ng-model
, which does exactly what you need - delay the changes in the models.
<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
For further information, take a loot at discussion here How to put a delay on AngularJS instant search?
Upvotes: 3