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 UI/UX Design

UI/UX Design by makandra brand

We make sure that your target audience has the best possible experience with your digital product. You get:

  • Design tailored to your audience
  • Proven processes customized to your needs
  • An expert team of experienced designers
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)