【发布时间】:2015-05-08 19:50:47
【问题描述】:
Hi all,
环境:vs 2013 express for web、hot towel angular 1.2、Breeze.WebApi2、sql server 2012 express。
我希望能够在我的网络应用程序的菜单中添加或删除项目,这可能吗?
我已经看到了 config.route.js,其中菜单由 getRoutes() 构建和返回:
function getRoutes() {
var rts = [
{
url: '/',
config: {
templateUrl: 'app/dashboard/dashboard.html',
title: 'dashboard',
settings: {
nav: 2,
content: '<i class="fa fa-dashboard"></i> Dashboard'
}
}
},
{
url: '/admin',
config: {
title: 'admin',
templateUrl: 'app/admin/admin.html',
settings: {
nav: 6,
content: "<i class='fa fa-dashboard'></i> GUIGUI's Homepage"
}
}
}, {
url: '/register',
config: {
title: 'register',
templateUrl: 'app/register/register.html',
settings: {
nav: 4,
content: '<i class="fa fa-lock"></i> Register'
},
visible: false
}
}, {
url: '/login',
config: {
title: 'login',
templateUrl: 'app/login/login.html',
settings: {
nav: 5,
content: '<i class="fa fa-lock"></i> Login'
}
}
}, {
url: '/',
config: {
title: 'Client',
templateUrl: 'app/client/client.html',
settings: {
nav: 1,
content: '<i class="fa fa-dashboard"></i> client'
}
}
}, {
url: '/mission',
config: {
title: 'Mission',
templateUrl: 'app/mission/mission.html',
settings: {
nav: 7,
content: '<i class="fa fa-lock"></i> mission'
}
}
}
, {
url: '/uploadFile',
config: {
title: 'uploadFile',
templateUrl: 'app/uploadFile/uploadFile.html',
settings: {
nav: 8,
content: '<i class="fa fa-lock"></i> uploadFile'
}
}
}
];
return rts;
}
(应用以 Client 开头)。
我创建了一个身份验证服务来了解当前用户(如果有登录用户)。
我的问题是:在哪里更新菜单更明智?
我认为 config.route.js 在开始时会加载一次。
我的目的是根据用户是否登录在菜单中添加或删除项目,可能吗?
在哪里注入 authenticationService 来更新菜单?
【问题讨论】: