我为“报告”添加了第二个路由器出口,并且该路由器出口位于报告的“布局”组件中。所有三个子路线都链接到“子菜单”组件中,当我回到“开始路线”(分配列表)时,就会出现我的问题,那就是我得到的
错误:无法匹配任何路由。 URL段:“ SE_556354-3353 /%2Freports” 错误
我如何回到“根” /父母(工作分配列表)?基本上,我如何才能在这些链接之间跳转?
这是相关的代码。
app.module
const routes = [
{ path: ':orgNoParam/organizational-unit/:unitIdParam/employments', component: EmployeeComponent },
{
path: ':orgNoParam/reports', component: ReportsComponent, children: [
{ path: '', component: AssignmentListComponent, outlet: 'content' },
{ path: 'managers', component: AssignmentCompactManagersComponent, outlet: 'content' },
{ path: 'employments', component: AssignmentCompactEmployeesComponent, outlet: 'content' }
]
}
];
reportsComponent(又称“布局”)
<div id="assignment">
<assignment-submenu></assignment-submenu>
<div>
<!--angular error messages-->
<error-message *ngIf="errorList?.length" [errorList]="errorList"></error-message>
</div>
<router-outlet name="content"></router-outlet>
Submenu.html(这是链接所在的位置)
<ul class="sub-menu" *ngIf="tempList && tempList.length">
<li *ngFor="let translation of tempList">
<ng-container *ngIf="translation.link=='reports'">
<a class="new-style" (click)="goToRoot()">{{ translation.name }}</a>
</ng-container>
<ng-container *ngIf="translation.link=='managers' || translation.link=='employments'">
<a class="new-style" [routerLink]="[{ outlets: { content: [translation.link] } }]">{{ translation.name }}</a>
</ng-container>
</li>
子菜单
goToRoot() {
this.router.navigate([this.orgNoParam, '/reports']);
}
答案 0 :(得分:0)
我通过将“ root”-子代的routerlink设置为“ routerLink =“ {{translation.link}}””来解决,然后设置了“ root”-子代的路径(路径为“ )更改为“ ../reports”和“瞧”。