2017-09-16 78 views
0

父路由PARAMS我已經路線是這樣的:進去canActivate

[ 
    { 
    path: ':orgName', 
    children: [ 
     { 
     path: '', 
     component: HomeComponent 
     canActivate: [AuthGuard], 
     }, 
     { 
     path: 'details', 
     component: DetailComponent 
     } 
    ] 
    } 
] 

如何訪問ORGNAME內AuthGuard的canActivate?

我試圖

canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { 
    console.log(route.params["orgName"]) 
} 

但它打印未定義

+0

'的console.log(route.parent)' –

回答

2

要訪問的父母的參數,可以試試這個: -

route.parent.params["orgName"]