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 }]);
原文地址:https://www.cnblogs.com/l000/p/7722522.html