Do I need to "unwatch" scope variables when the scope is being destroyed? Do I need to "unwatch" scope variables when the scope is being destroyed? angularjs angularjs

Do I need to "unwatch" scope variables when the scope is being destroyed?


A quick look at the source code will show you that the removal function returned by $watch doesn't do anything exotic. It simply removes an item from the scope.$$watchers array.

As such, once the scope is destroyed, the entire array goes with it, and the garbage collector will clean everything up for you.

Regardless of what you are watching, the watch itself is stored in the scope. Which is why, that in order to use $watch, you don't call angular.$watch, but rather you call $scope.$watch.


I also think that this should be explicitely explained in the documentation. I've deduced that unwatching was unnecessary from the angular source code which always ignores the result of scope.$watch (in ngIf, ngShow, ngRepeat, etc.).