我有多个命名插座和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>
当应用程序启动第一个链接的hrefbecаme
时/物品/ 1/1 /(articlesOutlet1:文章// articlesOutlet2:新闻)
点击此链接后,其href变为
/articles/1/1/(1/1/(articlesOutlet1:article//articlesOutlet2:news)//articlesOutlet1:article//articlesOutlet2:news)
这是一个糟糕的链接。我不希望改变href。如何实现?
答案 0 :(得分:0)
如果指定routerLink,请执行以下操作:
[routerLink]="['/articles/1/1', {outlets: {'articlesOutlet1': ['article'],'articlesOutlet2': ['news'] }}]
一切都按预期工作。