window-service - use $window instead of window

February 26, 2018 · View on GitHub

Instead of the default window object, you should prefer the AngularJS wrapper service $window.

Rule based on Angular 1.x

Styleguide Reference

Examples

The following patterns are considered problems;

/*eslint angular/window-service: 2*/

// invalid
window.alert('Hello world!'); // error: You should use the $window service instead of the default window object

The following patterns are not considered problems;

/*eslint angular/window-service: 2*/

// valid
$window.alert('Hello world!');

Version

This rule was introduced in eslint-plugin-angular 0.1.0