这是AdminRouting
path: 'adminHome',
component: adminHomeComponent,
children: [
{
path: '',
component: HomeComponent,
},
{
path: 'home',
component: HomeComponent,
},
{
path: 'users',
component: UserListComponent,
children: [
{
path: '',
component: HUComponent
},
{
path: ':id',
component: EntrepriseListComponent,
children: [
{
path: '',
component: HyComponent
},
{
path: ':id',
component: ListLaucauxComponent
},
]
}
]
},
]
},
我想获取List LocauxComponent通过单击企业的ID以获取此URL localhost:3000 / adminHome / users / {{id_user}} / {{id_entreprise}}
我试着用
[routerLink]="['/adminHome/users/:id',x.id]"
但我得到另一个类似的URL
http://localhost:3000/adminHome/users/%3Aid/58e35bdeaf314301ec86c249
答案 0 :(得分:1)
您的链接错误。使用[routerLink]
时,您不需要使用路径变量来调整:id
,而不需要使用路径变量,它被定义为占位符来放置id。
[routerLink]
应如下所示:
[routerLink]="['/adminHome/users', x.id]"
修改强>
为了构建具有更多参数的[routerLink]
,请执行以下操作:
[routerLink]="['/adminHome/users', param1, param2...]"
如果/adminHome/users/1/2
和param1=1
param2=2