【发布时间】:2017-11-23 14:21:42
【问题描述】:
我知道我可以使用基于角色/身份验证的路由,并且可以在路由模块中激活和停用它。
我还想隐藏基于 Guard 的选项。
我有一个[AuthGuard] 和一个[RoleGuard] 都实现canLoad()、canActivate() 等,并在路由处分配给相应的属性。
现在我想知道我是否可以对我作为数组制作的导航选项的链接做同样的事情
options: MenuItem[] = [
{
page: "Active Devices",
icon: "tablet",
path: "device-status",
canLoad:[AuthGuard]
}, {
page: "Data Sync",
icon: "refresh",
path: "data-sync",
canLoad: [AuthGuard]
}, {
page: "Add Users",
icon: "user",
path: "add-users",
canLoad: [AuthGuard]
}, {
page: "Change Password",
icon: "key",
path: "change-password",
canLoad: [AuthGuard]
}]
我想知道如何让 AuthGuard 中的 canLoad() 函数获得分配给该数组的 canLoad() 的值。
【问题讨论】:
标签: angular authorization angular-router angular5