我这样的路线:
[
{
path: ':orgName',
children: [
{
path: '',
component: HomeComponent
canActivate: [AuthGuard],
},
{
path: 'details',
component: DetailComponent
}
]
}
]
如何在AuthGuard的canActivate中访问orgName?
我试过
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
console.log(route.params["orgName"])
}
但它打印未定义的
答案 0 :(得分:3)
要访问父母的参数,请尝试: -
route.parent.params["orgName"]