【发布时间】:2019-04-26 22:35:46
【问题描述】:
我正在尝试访问孩子的参数,但似乎无法访问它们。我的路线安排如下:
const clientsRoutes: Routes = [
{
path: 'clients',
component: ClientIndexPage,
// loadChildren: "./client-index/client-index.module#ClientIndexPageModule",
canActivate: [AuthGuard],
},
{ path: 'clients/:id',
component: ClientDetailPage,
canActivate: [AuthGuard],
canActivateChild: [AuthGuard],
children: [
{
path: 'profile',
component: ProfilePage
// loadChildren: './client-detail/profile/profile.module#ProfilePageModule',
},
{
path: 'finance',
component: FinancePage
// loadChildren: './client-detail/finance/finance.module#FinancePageModule'
},
{
path: '',
redirectTo: 'profile',
pathMatch: 'full'
}
]
},
];
从ClientDetailPage我可以访问:id,但是当我尝试从ProfilePage获取它时,它无法访问:
// ClientDetailsPage
console.log(this.route.snapshot.paramMap.get('id)
// returns the correct value
// ProfilePage
console.log(this.route.snapshot.paramMap.get('id))
// returns null
console.log(this.route.parent)
//returns null
我有什么遗漏吗?值得注意的是,ClientDetailsPage 和 ProfilePage 都有单独的模块。
【问题讨论】:
-
嗯似乎没有帮助
-
你有这方面的闪电战吗?