1

我有多个命名的插座和 routerLinks 来为 Angular2 组件中的其他组件提供插座。

<p><a [routerLink]="['1/1', {outlets: {'articlesOutlet1': ['article'],'articlesOutlet2': ['news'] }}]"> Provide outlets 1/1</a></p>
<p><a [routerLink]="['1/2', {outlets: {'articlesOutlet1': ['article'],'articlesOutlet2': ['news'] }}]"> Provide outlets 1/2</a></p>
<p><a [routerLink]="['1/3', {outlets: {'articlesOutlet1': ['article'],'articlesOutlet2': ['news'] }}]"> Provide outlets 1/3</a></p>
<div class="flex-container">
    <div class="flex-item"><router-outlet></router-outlet></div>
    <div class="flex-item"><router-outlet name="articlesOutlet1"></router-outlet></div>
    <div class="flex-item"><router-outlet name="articlesOutlet2"></router-outlet></div>
</div>

当应用程序启动第一个链接的 href 时

/articles/1/1/(articlesOutlet1:article//articlesOutlet2:news)

点击这个链接后,它的href变成了

/articles/1/1/(1/1/(articlesOutlet1:article//articlesOutlet2:news)//articlesOutlet1:article//articlesOutlet2:news)

这是一个糟糕的链接。我不想改变href。如何实现?

完整示例在这里 http://plnkr.co/edit/EJOANe?p=preview

4

1 回答 1

1

如果指定 routerLink 如下:

[routerLink]="['/articles/1/1', {outlets: {'articlesOutlet1': ['article'],'articlesOutlet2': ['news'] }}]

一切都按预期工作。

于 2016-10-19T11:18:26.283 回答