AngularJS:清除$腕表 [英] AngularJS : Clear $watch
本文介绍了AngularJS:清除$腕表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的AngularJS应用的手表功能。
I have a watch function in my AngularJS application.
$scope.$watch('quartzCrystal', function () {
...
}
不过,经过一些条件(在我的例子,在我单页的应用程序)我要停止手表(像清理超时)。
However, after some condition (in my example, changing the page at my single-page application) I want to stop that watch (as like clearing timeout).
我怎么能这样做?
推荐答案
$观看
返回注销功能。调用它会注销 $观察家
。
$watch
returns a deregistration function. Calling it would deregister the $watcher
.
var listener = $scope.$watch("quartz", function () {});
// ...
listener(); // Would clear the watch
这篇关于AngularJS:清除$腕表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文