Why can my code not find the AngularJS $interval? -


my angularjs code trying call $interval , there's problem in vs2013 saying not found. here's code:

var apprun = [     '$rootscope',     function (         $rootscope         ) {          // not work         $interval(userservice.isauthenticated(), 5000);         // works         $rootscope.$interval(userservice.isauthenticated(), 5000);      }]  app.run(apprun); 

can tell me why call $interval. ... not work. why need put $rootscope before ?

$interval angular service need inject inject $rootscope:

var apprun = [     '$rootscope', '$interval',     function ($rootscope, $interval) {         $interval(userservice.isauthenticated(), 5000);     }]  app.run(apprun); 

regarding why $rootscope.$interval seems work - may have attached $interval service $rootscope on other part of application. it's not built-in on $rootscope.

in case, should used via injection.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -