$on
and $watch
deregistration callbacks to be saved in a variable JS-0529Watch 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
$rootScope.$on('event', function () {
// ...
});
$scope.$on('event', function () {
// ...
});
var unregister = $rootScope.$on('event', function () {
// ...
});