当前位置:Gxlcms > JavaScript > AngularJS 监听变量变化的实现方法

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

时间:2021-07-01 10:21:17 帮助过:1人阅读

如下所示:

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 监听变量变化的实现方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。

人气教程排行