我有一些网站:
<router-outlet></router-outlet>
还有另一个组件
(...)navigation bar(...)
<router-outlet name="mainPanel"></router-outlet>
(...)
我将路线设置如下:
export const routes: Routes = [
{ path: '', redirectTo: AppUrls.LayoutComponentUrl, pathMatch: 'full' },
{ path: AppUrls.LayoutComponentPath, component: LayoutComponent, canActivate: [AuthGuard],
runGuardsAndResolvers: 'always', children: [
{ path: '', component: MainDataPaneComponent, outlet: 'mainPanel', pathMatch: 'full' },
{ path: 'results', component: MainDataPaneComponent, outlet: 'mainPanel' },
{ path: 'chartPage', component: ChartComponent, outlet: 'mainPanel' }
] },
{ path: AppUrls.LoginComponentPath, component: LoginComponent }
];
@NgModule({
imports: [BrowserModule, RouterModule.forRoot(routes, {enableTracing: true, preloadingStrategy: PreloadAllModules})],
exports: [RouterModule],
providers: [AuthGuard]
})
我还在下面相关的地方添加了routerLink:
<a [routerLink]="['/simbalweb', { outlets: { mainPanel: ['results'] } }]">Result</a>
问题在于它会像这样生成URL:
/web/(mainpanel:results)
在重新输入该网址(或刷新网络)后,它还会返回:
NavigationError {id: 1, url: "/web/(mainpanel:result)"
因为路线没有该补丁。
我的目的是允许使用以下地址重新进入网站
/web/(mainpanel:results)
或者以这种方式显示它-我希望将其显示如下:
/web/results
有可能吗?谢谢您的帮助。