AngularJS 监听变量变化 》
vartimeout;$scope.$watch('search.subj',function(newVal, oldVal) {if(newVal !== oldVal) {if(timeout) $timeout.cancel(timeout); timeout = $timeout(function() {$scope.doSearch(); }, 800); }},true);
时间:2022-11-11 10:56:46
AngularJS 监听变量变化 》
vartimeout;$scope.$watch('search.subj',function(newVal, oldVal) {if(newVal !== oldVal) {if(timeout) $timeout.cancel(timeout); timeout = $timeout(function() {$scope.doSearch(); }, 800); }},true);