Angular JS $locationChangeStart get next url route object

后端 未结 4 2093
忘掉有多难
忘掉有多难 2021-02-14 08:44

I am trying to implement Authorization on my angular application, when a route is changed I want to check whether the route is authorized for user or not. I tried with $ro

4条回答
  •  遇见更好的自我
    2021-02-14 08:53

    You can also use $location provider to do this like :

    .run(['$rootScope','$location',function($rootScope,$location){
          $rootScope.$on('$routeChangeStart', function(event,next, current) {
           console.log('next',next);
           console.log('location',$location.path());
           console.log('location',$location.search()); // for route params
         });
        }])`
    

提交回复
热议问题