#使用AngularJS时,当路由发生改变时,我们需要做某些处理,此时可以监听路由事件,常用的是$routeStartChange, $routeChangeSuccess

##使用场景:在路由配置文件routeConfig.js,对路由跳转进行特殊处理经常用到

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。
 app.run(['$rootScope', '$location', function($rootScope, $location) {
        /* 监听路由的状态变化 */
        $rootScope.$on('$routeChangeStart', function(evt, next, current){
          console.log('route begin change');
        }); 
        $rootScope.$on('$routeChangeSuccess', function(evt, current, previous) {
          console.log('route have already changed :'+$location.path());
        }); 
    }])

  

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄