Shawn Shawn - 1 month ago 4
AngularJS Question

Angular UI Router 1.0 - why $scope.$watch('$destroy') is called without leaving state?

Check the plunker here:

As far as I know,

should be called when $scope is about to be destroyed.

The example above shows that when entering into a state, it's
is called right away. Why is that?


Instead of:

$scope.$watch('$destroy', ... 

We should use

$scope.$on('$destroy', ...