javascript - $rootScope Event not working Angularjs -


i have declared $rootscope.$on function under myapp.run check token value in every authenticated page.but not working.i not understand why not working.please me.

app.js

myapp.run(['$rootscope','$state', '$location', 'loginservice', function ($rootscope,$state, $location, loginservice) {      console.log(" under run => ");     $rootscope.$on('routechangestart', function (event, next, current) {         /*if route authenticated check if user has access token, else return login screen*/          console.log(event);          if (next.$$route.authenticated) {              var userauth = loginservice.getusertoken();             console.log(" usertoken => " +userauth);             if (!userauth) {                 $location.path("/");             }         }      });  }]); 

code print on console "under run =>" not printing event object , not check if condition.

be care of $:

$rootscope.$on('$statechangestart',...) 

Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -