当前位置:主页 > 网页前端 > AngularJS >

AngularJS 监听变量变化的实现方法

时间:2022-01-06 09:20:48 | 栏目: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);

您可能感兴趣的文章:

相关文章