【发布时间】:2016-01-09 22:46:24
【问题描述】:
我一直在玩 ES6 和 Angular,我正在使用 eslint-plugin-angular 来验证我的 javascript。我有以下服务:
export function runBlock ($rootScope, $state, $log) {
'ngInject';
$rootScope.$on( '$stateChangeStart', function(event, toState) {
// ...
} );
但是eslint 给了我以下错误:
The "$on" call should be assigned to a variable, in order to be
destroyed during the $destroy event
我的意思是我理解这个警告,但我在以前的 Angular 项目中从来没有这样做过,我应该按照错误提示做吗?为什么需要它/良好做法?
eslint-plugin-angular 的文档参考了John Papa's angular styleguide,但我并没有真正找到关于这种情况的提及。
【问题讨论】:
标签: javascript angularjs eslint