【发布时间】:2020-01-24 09:32:12
【问题描述】:
我想获取我在使用 route.params 在 Angular 中路由时传递的多个 id。 这是路线.ts
{path:'section/:id/:id', component: SubsectionsComponent}
这就是我从 component.ts 路由的方式
onSectionClick(id1, id2){
this.router.navigate(['/path/',id1,id2], {relativeTo:this.route})
}
这就是我在它路由的组件中获取的方式。
constructor(private route: ActivateRoute){}
this.route.params.subscribe(
(route)=>{
console.log(route)
}
)
但它只记录参数中的一个 id。
【问题讨论】:
-
在路径中使用不同的名称。 :id1/:id2 例如
标签: angular typescript angular6