Reputation: 24562
My AngularJS Code is trying to call $interval and there's a problem in VS2013 saying not found. Here's the code:
var appRun = [
'$rootScope',
function (
$rootScope
) {
// This does not work
$interval(userService.isAuthenticated(), 5000);
// This works
$rootScope.$interval(userService.isAuthenticated(), 5000);
}]
app.run(appRun);
Can someone tell me why the call to $interval. ... does not work. Why do I need to put $rootScope before it ?
Upvotes: 0
Views: 90
Reputation: 17064
$interval
is an Angular service that you need to inject just as you inject $rootScope
:
var appRun = [
'$rootScope', '$interval',
function ($rootScope, $interval) {
$interval(userService.isAuthenticated(), 5000);
}]
app.run(appRun);
Regarding why $rootScope.$interval
seems to work - you may have attached the $interval
service to the $rootScope
on some other part of your application. It's not built-in on the $rootScope
.
In any case, it should be used via injection.
Upvotes: 3