github地址:https://github.com/LiangJingxuan

AngularJs控制器运行前方法,操控导航栏隐藏

有些二级页面或三级页面不希望出现include加载的导航或其他内容,这时使用module中的run方法,每进到一个控制器中会最先执行该方法

 1 angular.module.run(['$rootScope','$anchorScroll','$http','$state',function($rootScope,$anchorScroll,$http,$state){
 2     $rootScope.$on('$stateChangeStart',function(event,toState){
 3         // 隐藏导航操作
 4         $rootScope.tsnavScope = true;
 5          if(toState.name === 'register' || toState.name === 'residenceResourceDetails' || toState.name === 'bClientDetails'){
 6              $rootScope.tsnavScope = false;
 7          }else{
 8              $rootScope.tsnavScope = true;
 9          }
10     });
11 }]);

 

posted @ 2017-10-24 11:10  热爱世界的liang  阅读(240)  评论(0编辑  收藏  举报