Skip to content

Latest commit

 

History

History
45 lines (28 loc) · 1.3 KB

interval-service.md

File metadata and controls

45 lines (28 loc) · 1.3 KB

interval-service - use $interval instead of setInterval

Instead of the default setInterval function, you should use the AngularJS wrapper service $interval

Rule based on Angular 1.x

Styleguide Reference

Examples

The following patterns are considered problems;

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

// invalid
setInterval(function() {
    // ...
}, 1000) // error: You should use the $interval service instead of the default window.setInterval method

// invalid
window.setInterval(function() {
    // ...
}, 1000) // error: You should use the $interval service instead of the default window.setInterval method

The following patterns are not considered problems;

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

// valid
$interval(function() {
    // ...
}, 1000)

Version

This rule was introduced in eslint-plugin-angular 0.1.0

Links