I have a strange issue where I have the following route setup:
const routes: Routes = [
{
path: '',
component: CustomerControlPage,
children: [
{
path: 'add',
pathMatch: 'full',
component: AddCustomerViewComponent
},
{
path: 'edit/:id',
component: EditCustomerViewComponent,
children: [
{
path: 'user',
component: CustomerAddUserViewComponent,
children: [
{
path: 'select',
component: CustomerAddUserSelectViewComponent,
pathMatch: 'full'
},
{
path: '',
component: CustomerAddUserBaseViewComponent,
pathMatch: 'full'
}
]
},
{
path: 'app',
component: CustomerAddAppViewComponent,
children: [
{
path: 'select',
component: CustomerAddAppSelectViewComponent,
pathMatch: 'full'
},
{
path: '',
component: CustomerAddAppBaseViewComponent,
pathMatch: 'full'
}
]
},
{
path: '',
component: CustomerEditBaseViewComponent,
pathMatch: 'full'
}
]
},
{
path: '',
pathMatch: 'full',
component: CustomerViewComponent
}
]
}
];
I can see at the component under the URL "edit/:id/user" can't retrieve the URL parameter 'id' from the parent component.
Normally I can get the URL parameter of the parent using the following code, in my case the parent paramMap is always null.
this.activatedRoute.parent.paramMap.subscribe(param => {
console.log(param.get('id'))
});
If I want to read the parameter id using the following code I get a null object back:
this.activatedRoute.params.subscribe(param => {
console.log(param.get('id'));
});
Am I missing something? Sorry for my bad english...
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…