相关疑难解决方法(0)

在Angular2中传递多个路径参数

是否有可能通过多种途径PARAMS比如像下面需要传递id1id2component B

@RouteConfig([
    {path: '/component/:id :id2',name: 'MyCompB', component:MyCompB }
])
export class MyCompA {
  onClick(){
    this._router.navigate( ['MyCompB', {id: "someId", id2: "another ID"}]);
     }
}
Run Code Online (Sandbox Code Playgroud)

angular2-routing angular

60
推荐指数
3
解决办法
7万
查看次数

如何从 Angular 6 中的路由参数获取多个 ID?

我想获取我在使用 route.params 在 Angular 中路由时传递的多个 id。这是 route.ts

{path:'section/:id/:id', component: SubsectionsComponent}
Run Code Online (Sandbox Code Playgroud)

这就是我从 component.ts 路由的方式

onSectionClick(id1, id2){
    this.router.navigate(['/path/',id1,id2], {relativeTo:this.route})
  }
Run Code Online (Sandbox Code Playgroud)

这就是我在它路由的组件中获取的方式。

constructor(private route: ActivateRoute){}
this.route.params.subscribe(
      (route)=>{  
        console.log(route)
      }
    )
Run Code Online (Sandbox Code Playgroud)

但它只从参数中记录一个 id。

typescript angular angular6

6
推荐指数
1
解决办法
2469
查看次数

标签 统计

angular ×2

angular2-routing ×1

angular6 ×1

typescript ×1