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>