站长资源网络编程
AngularJS 监听变量变化的实现方法
简介如下所示:var timeout;$scope.$watch('search.subj',function (newVal, oldVal) {if (newVal !== oldVal) {if (timeout) $timeout.cancel(timeout);timeout = $time
如下所示:
var timeout;
$scope.$watch('search.subj',function (newVal, oldVal) {
if (newVal !== oldVal) {
if (timeout) $timeout.cancel(timeout);
timeout = $timeout(function() {
$scope.doSearch();
}, 800);
}
}, true);
以上这篇AngularJS 监听变量变化的实现方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。
上一篇:vue发送ajax请求详解