Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
42 lines (26 sloc) 1.08 KB

on-watch - require $on and $watch deregistration callbacks to be saved in a variable

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

Examples

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 () {
    // ...
});

Version

This rule was introduced in eslint-plugin-angular 0.1.0

Links

You can’t perform that action at this time.