在 Angular2 中传递多个路由参数 [英] Passing Multiple route params in Angular2

查看:28
本文介绍了在 Angular2 中传递多个路由参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以传递多个路由参数,例如如下需要将 id1id2 传递给 component B

Is it possible to pass multiple route params e.g. like below need to pass id1 and id2 to the component B

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

推荐答案

OK 意识到一个错误..它必须是 /:id/:id2

OK realized a mistake .. it has to be /:id/:id2

无论如何在任何教程或其他 StackOverflow 问题中都没有找到.

Anyway didn't find this in any tutorial or other StackOverflow question.

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

这篇关于在 Angular2 中传递多个路由参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆