在angular.js中有$ watch来查看更新的范围变量。但是我能做些什么,例如在变量更新之前执行函数
答案 0 :(得分:3)
观察价值变化
var watchVar = $scope.$watch('value', function(newValue , oldValue){
if(newValue!=oldValue){
//value changed remove watch
watchVar();
}
});
答案 1 :(得分:1)
//try this (please inject $interval service to your controller)
var execueMe = function () {
//your stuff
}
$interval(execueMe, 3000); //will trigger every 3 seconds