Read more

AngularJS: How to remove a watch

Arne Hartherz
December 12, 2014Software engineer at makandra GmbH

Sometimes you want Angular to watch an object only until a certain state is reached (e.g. an object appears in the scope).

Illustration online protection

Rails professionals since 2007

Our laser focus on a single technology has made us a leader in this space. Need help?

  • We build a solid first version of your product
  • We train your development team
  • We rescue your project in trouble
Read more Show archive.org snapshot

Angular's $watch returns a method that you can call to remove that watch. For example:

unwatch = $scope.$watch 'user', (user) ->
  if user?
    ... # do something
    unwatch()

That's it.

Posted by Arne Hartherz to makandra dev (2014-12-12 10:59)