标签: javascript angularjs angular-ui-router
检查plunker here。
据我所知,当$ scope即将被销毁时,应调用$scope.$watch('$destroy')。
$scope.$watch('$destroy')
上面的示例显示,当进入状态时,会立即调用它$scope.$watch('$destroy')。那是为什么?
答案 0 :(得分:2)
而不是:
$scope.$watch('$destroy', ...
我们应该使用
$scope.$on('$destroy', ...