Hide title depending on the result of the localStorage
- 主要语言
- JavaScript
- 星标
- 11.3k
- 派生
- 3k
- PR 合并指标
- 30 天内没有已合并 PR
描述
After the user logs in to the system, I store his data in a localStorage, within a service. Based on this, I need to set up a menu with the permissions of each user. Each menu item is in a BlurAdmin module. I can recover the data, however I can not hide the link, if the user does not have the permission. Here is the code:
`(function() {
'use strict';
angular.module('BlurAdmin.pages.dashboard', [])
.config(routeConfig);
/** @ngInject */
function routeConfig($stateProvider) {
$stateProvider
.state('dashboard', {
resolve: {
user: function(baSidebarService, $q){
var user = JSON.parse(baSidebarService.getStorage());
console.log(user)
var roles = ["GERENTE","ADMIN"];
user.roles.forEach(function(role){
if(roles.includes(role.nome)){
console.log('ok')
}
else{
return;
}
})
}
},
// if baSidebarService.getStorage() == true
url: '/dashboard',
templateUrl: 'app/pages/dashboard/dashboard.html',
title: "Dashboard",
sidebarMeta: {
icon: 'ion-android-home',
order: 0,
},
});
}
})(); `
Note that within the loop, I make a check if the user data is the same as the rules. The problem is that even though I check that they are different, I can not hide the Dashboard link. I already tried everything, with no success.
How could I do this, for example, depending on localStorage data:
` // if baSidebarService.getStorage() == true
url: $scope.dashboard,
templateUrl: $scope.template,
title: $scope.title,
sidebarMeta: $scope.sidebar,`
贡献指南
这个仓库没有索引到贡献指南
评估
这个 Issue 还没有评估数据。