AngularJS 监听变量变化 》
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 监听变量变化 》
var timeout; $scope.$watch('search.subj',function (newVal,oldVal) { if (newVal !== oldVal) { if (timeout) $timeout.cancel(timeout); timeout = $timeout(function() { $scope.doSearch(); },800); } },true);