【发布时间】:2018-08-27 05:14:08
【问题描述】:
我的 route.ts 中有这个
path: 'profile/:id',
component: ProfileComponent,
canActivate: [SiteRouteGuard],
children: [
{
path: 'albums',
component: AlbumsComponent,
canActivate: [SiteRouteGuard]
},
...
]
现在在我的 profile.ts 我得到了这个
localhost:4200/profile/45666
当我路由到作为我 profile.ts 的子目录的 album.ts 时
localhost:4200/profile/45666/albums
现在我在我的专辑中。ts 如何获得 id 45666?
我尝试使用ActivatedRoute:
console.log(this._route.snapshot.params.id) >> undefined
【问题讨论】: