Angular UI Router 1.0 - 为什么$ scope。$ watch('$ destroy')在没有离开状态的情况下被调用?

时间:2016-09-15 04:26:07

标签: javascript angularjs angular-ui-router

检查plunker here

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

上面的示例显示,当进入状态时,会立即调用它$scope.$watch('$destroy')。那是为什么?

1 个答案:

答案 0 :(得分:2)

而不是:

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

我们应该使用

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