【发布时间】:2017-11-07 10:27:40
【问题描述】:
在我们的主 app.component 路由中,我们有这样的:
{ path: 'store', loadChildren: './store/store.module#StoreModule', canActivate: [LoginGuard] },
然后在模块中我们有这样的路由:
const routes: Routes = [
{ path: '', component: StoreStartPageComponent},
{
path: ':name/:id', component: CategoryPageComponent,
children: [
{
path: ':childName/:childId', component: CategorySubPageComponent,
children: [
{ path: ':childName/:childId', component: CategorySubSubPageComponent }
]
}
]
},
{ path: '**', component: PageNotFoundComponent }
];
现在我需要的是获取 param['id'] 之类的:
this.route.params
.switchMap((params: Params) => params['id'])
.subscribe(id => console.log('id', id));
奇怪的是,这只适用于 path: ':name/:id' 而不是它的孩子。我错过了什么?
【问题讨论】:
标签: angular routing lazy-loading angular-routing routeparams