Route not changing on $routeChangeStart


#1

Hello. why $routeChangeStart didn’t changing when I applied it on $rootScope.on() ?

this is my code:

app.run(function($rootScope, $location, loginService){
  var routespermission=['/home'];  //route that require login
  $rootScope.$on('$routeChangeStart', function(){
    if( routespermission.indexOf($location.path()) !=-1)
    {
      var connected=loginService.islogged();
      connected.then(function(msg){
        if(!msg.data) $location.path('/login');
      });
    }
  });
});

#2

ionic uses the angularjs extension - angular-ui.router.
Please use the events of that extension:
https://github.com/angular-ui/ui-router/wiki and search for events