3
我的路由配置方式如下:第一個孩子航線後Angular2路由工作不被加載
RouterModule.forRoot([
{ path: '', redirectTo: 'main', pathMatch: 'full' },
{ path: 'main', component: SummaryComponent, children: [
{ path: 'data/:deviceId/:incidentId', component: DeviceMetricsComponent },
{ path: 'incident/analysis/:incidentId', component: IncidentAnalysisComponent },
]
},
{ path: 'test', component: TestFullPageComponent, children: [
{ path: 'test2', component: TestFullPageChildComponent}
]
},
{ path: 'logs/jobs/:jobtype', component: JobLogsComponent, pathMatch: 'full' },
{ path: '**', redirectTo: 'main' }
])
這裏是我的「主」模板:
<div class="row">
<div class="col-md-12">
<!-- Some links are in this table that load into the router-outlet below -->
<app-incident-node-table [tableTitle]="incidentNodeTableTitle" [parentSubject]="incidentNodesSubject"></app-incident-node-table>
</div>
</div>
<div class="row" style="margin-top: 500px;">
<div class="col-md-12">
<div id="childResult">
<router-outlet></router-outlet>
</div>
</div>
</div>
當我第一次導航到頁面並單擊一個鏈接,它按預期加載到<router-outlet>
。在那一點上我的網址變得像http://localhost:4200/main/incident/analysis/3816913766390440113
。
該表中的任何其他鏈接都會顯示不同的URL,但是一旦單擊它們,新內容就不會加載到<router-outlet>
中。
編輯: 在IncidentNodeTable模板中的鏈接看起來是這樣的:
<span><a pageScroll [pageScrollOffset]="60" [routerLink]="['/main/incident/analysis', row.IncidentId]">Analyze</a></span>