我有一个搜索字段,我想搜索文本框的绑定反映了一段时间后。提前谢谢。
我的代码
<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。如果你也能分享你的指令,那将会有帮助。