Sometimes you want Angular to watch an object only until a certain state is reached (e.g. an object appears in the scope).
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 09:59)