routerLink加载嵌套的parent-> child-> child的页面 [英] routerLink to load a page of a nested parent->child->child

查看:69
本文介绍了routerLink加载嵌套的parent-> child-> child的页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用routerLink加载具有两个命名插座的parent-> child-> child路由器插座的页面.

I am trying to use routerLink to load a page of a parent->child->child router outlet with two named outlets.

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

1)如果我将URL粘贴到浏览器中,它将起作用

1) If I paste the URL into the browser it works

2)如果我使用下面的方法,它将起作用:

2) If I use the below it works:

this.router.navigateByUrl('output/(output:details/(data:distributions))');

如果我尝试在angular2选项卡组件中使用路由器链接,将无法正常工作

If I try to use router link in an angular2 tab component IT DOES NOT WORK

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

 ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'output'

我只有一个父级->子级的其他链接确实起作用:

My other links that only have a parent-> child do work:

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

我必须假设我为parent-> child-> child设置了格式错误的routerLink.

I have to assume I am formatting the routerLink incorrect for the parent->child->child.

推荐答案

您可以这样做:

routerLink = [
  '/output', {outlets: {'output': ['details', {outlets: {'data': ['distributions']}}]}}
]);

这篇关于routerLink加载嵌套的parent-> child-> child的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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