angular 全局 监听路由变化

 

 

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());
    });
}]);

 

posted @ 2017-09-21 14:17  快乐的咸鱼  阅读(1319)  评论(0编辑  收藏  举报