Bonjour ,
dans mon code j'ai utilise $routeprovider

mais dans cette exemple de fonction run ecrite par $stateprovider

donc ma question c'est comment je peux changer cette fonction en utilise $rootproveider


merci par avance

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 /**
       * Run block
       */
      angular
        .module('HMZAdminApp')
        .run(run);
 
      run.$inject = ['$rootScope', '$location'];
 
      function run($rootScope, $location, $state, LoginService) {
     $rootScope.$on('$stateChangeStart', 
          function(event, toState, toParams, fromState, fromParams){ 
      console.log('Changed state to: ' + toState);
          });
 
          if(!LoginService.isAuthenticated()) {
            $state.transitionTo('login');
          }
 
 
      }