RouterLink- angular2,子路由和查询字符串

时间:2017-06-09 04:45:00

标签: angular angular2-routing

angular2,

如何以此格式向嵌套路由添加查询查询?

这适用于ts文件:

routerLink = ['/output', {outlets: {'output': ['details']}}] 

http://localhost:4200/#/output/(output:details)

如何修改添加查询parm? 网址应如下所示:

    http://localhost:4200/#/output/(output:details;id=1)

1 个答案:

答案 0 :(得分:1)

您可以将参数作为对象传递给URL段,如下所示:

router.navigate([
     '/inbox', 33, {details: true}, 'messages', 44, {mode: 'preview'}
])

所以在你的情况下它会是这样的:

routerLink = ['/output', {outlets: {'output': ['details', {id: 1}]}}] 
                                                           ^^^^^

这将生成URL:

/output/(output:details;id=1)