[英]how to continuously watch for scope variable until update
In angular.js there is $watch to watch the scoped variables for updates. 在angular.js中,有$ watch来监视作用域变量的更新。 but is there anything that I can do, such as execute a function until the variable gets updated
但是有什么我可以做的,例如执行一个函数直到变量被更新
watch until value change 观察直到价值改变
var watchVar = $scope.$watch('value', function(newValue , oldValue){
if(newValue!=oldValue){
//value changed remove watch
watchVar();
}
});
//try this (please inject $interval service to your controller)
var execueMe = function () {
//your stuff
}
$interval(execueMe, 3000); //will trigger every 3 seconds
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.