Sibiraj
Sibiraj

Reputation: 4756

how to continuously watch for scope variable until update

In angular.js there is $watch to watch the scoped variables for updates. but is there anything that I can do, such as execute a function until the variable gets updated

Upvotes: 0

Views: 172

Answers (2)

Durga
Durga

Reputation: 15614

watch until value change

var watchVar = $scope.$watch('value', function(newValue , oldValue){
  if(newValue!=oldValue){
  //value changed remove watch
  watchVar();
 }
});

Upvotes: 3

Nainish Modi
Nainish Modi

Reputation: 488

   //try this (please inject $interval service to your controller)
    var execueMe = function () {
        //your stuff
    }

    $interval(execueMe, 3000); //will trigger every 3 seconds     

Upvotes: 1

Related Questions