我使用Blur Admin开发Web App
我有服务来检查每个用户的权限
如何通过pages.module.js和LVS.module.js中的权限服务隐藏菜单
PS。我的英语很差。
我的代码
App.js:
'use strict';
var app = angular.module('BlurAdmin', [
'ngAnimate',
'ui.bootstrap',
'ui.sortable',
'ui.router',
'ngTouch',
'toastr',
'smart-table',
"xeditable",
'ui.slimscroll',
'ngJsTree',
'angular-progress-button-styles',
'BlurAdmin.theme',
'BlurAdmin.pages',
'ngRoute',
'ngCookies',
])
;
pages.module.js:
(function () {
'use strict';
angular.module('BlurAdmin.pages', [
'ui.router',
'BlurAdmin.pages.dashboard',
'BlurAdmin.pages.ui',
'BlurAdmin.pages.components',
'BlurAdmin.pages.form',
'BlurAdmin.pages.tables',
'BlurAdmin.pages.charts',
'BlurAdmin.pages.maps',
'BlurAdmin.pages.profile',
'BlurAdmin.pages.Base',
'BlurAdmin.pages.Common',
'BlurAdmin.pages.Home',
'BlurAdmin.pages.MSS',
'BlurAdmin.pages.LVS',
'BlurAdmin.pages.SHS',
'BlurAdmin.pages.OTS',
'BlurAdmin.pages.TCS',
])
.config(routeConfig).run(run);
/** @ngInject */
function routeConfig($urlRouterProvider, baSidebarServiceProvider) {
$urlRouterProvider
.otherwise('Login');
}
})();
LVS.module.js:
(function () {
'use strict';
angular.module('BlurAdmin.pages.LVS', [
])
.config(routeConfig);
/** @ngInject */
function routeConfig($stateProvider) {
$stateProvider
.state('LVS', {
url: '/Leave',
template : '<ui-view></ui-view>',
//controller: 'LeaveManagementCtrl',
abstract: true,
title: 'Leave Management',
sidebarMeta: {
icon: 'ion-android-calendar',
order: 30,
},
resolve: {
user: function (AuthService, $q) {
var d = $q.defer();
if (AuthService.isAuthenticated()) {
// I also provide the user for child controllers
d.resolve(AuthService.UserDomain());
} else {
// here the rejection
d.reject('not logged');
}
return d.promise;
}
},
})
.state('LVS.LeaveList', {
url: '/List',
templateUrl: 'app/pages/ESS-TA/LeaveManagement/LeaveList.html',
controller: 'LVSCtrl',
title: 'Leave List',
params: {
obj: null,
},
sidebarMeta: {
order: 10,
},
})
.state('LVS.LeaveReport', {
url: '/Report',
templateUrl: 'app/pages/ESS-TA/LeaveManagement/LeaveReport.html',
title: 'Leave Report',
sidebarMeta: {
order: 30,
},
});
}
})();