是否有任何方法ng-model指令绑定数据后10秒或一段时间



我有一个搜索字段,我想搜索文本框的绑定反映了一段时间后。提前谢谢。

我的代码

<div ng-controller="appointment as vm">
Search By Description :  <input class="form-control" placeholder="search by    description" type="text" ng-model="vm.filterText" />
{{vm.filterText}} </div>

您可以使用ng-model-options作为您的输入字段

<input type="text" ng-model="vm.filterText" ng-model-options="{debounce: { 'default': 10000}"/>

ng-model-options指令一定会帮到你。您可以在指定的时间后或在模糊事件时更新绑定。

试试这个代码

 Search By Description :  <input class="form-control" placeholder="search by description" type="text" ng-model="vm.filterText" ng-model-options={ debounce: 1000 } />

参见ng-model-options http://learnit.visrosoftware.com/try/kfPWlU4N示例

尝试在你的指令中使用$interval。如果你也能分享你的指令,那将会有帮助。

最新更新