Angular UI Router 1.0——为什么在不离开state的情况下调用$scope.$watch('

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

本文关键字:调用 情况下 scope watch state Router UI 为什么 离开 不离 Angular      更新时间:2023-09-26

检查这里的活塞

据我所知,$scope.$watch('$destroy')应该在$scope即将被销毁时调用。

上面的例子表明,当进入一个状态时,它的$scope.$watch('$destroy')被立即调用。为什么呢?

而不是:

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

我们应该使用

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