Watch and On methods on the scope object should be assigned to a variable, in order to be deleted in a $destroy event handler
Rule based on Angular 1.x
The following patterns are considered problems;
/*eslint angular/on-watch: 2*/
// invalid
$rootScope.$on('event', function () {
// ...
}); // error: The "$on" call should be assigned to a variable, in order to be destroyed during the $destroy event
The following patterns are not considered problems;
/*eslint angular/on-watch: 2*/
// valid
$scope.$on('event', function () {
// ...
});
// valid
var unregister = $rootScope.$on('event', function () {
// ...
});
This rule was introduced in eslint-plugin-angular 0.1.0