[英]How to configure Angular secondary route?
I am trying to configure secondary routes within a component where the content of the routes are displayed in tabs 我正在尝试在组件中配置辅助路由,其中路由的内容显示在选项卡中
In app.component.html
在
app.component.html
<a class="list" [routerLink]="[{outlets:{primary:'variationMargin', futuresMargin:'futuresMargin'}}]" routerLinkActive="router-link-active">Projected VM</a>
In variation-margin.routing.module.ts
I am trying to configure secondary routes within a component where the content of the routes are displayed in tabs 在
variation-margin.routing.module.ts
我尝试在组件中配置辅助路由,其中路由的内容显示在选项卡中
In app.component.html
在
app.component.html
<a class="list" [routerLink]="[{outlets:{primary:'variationMargin', futuresMargin:'futuresMargin'}}]" routerLinkActive="router-link-active">Projected VM</a>
In variation-margin.routing.module.ts
在
variation-margin.routing.module.ts
const routes: Routes = [{
path: 'variationMargin',
component: VariationMarginComponent,
canActivate: [AuthGuard],
}, {
path: 'futuresMargin,
component: FuturesMarginComponent,
canActivate: [AuthGuard],
outlet: 'futuresMargin'
}];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class VariationMarginRoutingModule { }
Within the template for VariationMarginComponent
I have tabs 在
VariationMarginComponent
的模板中,我具有标签
tab1 -> the primary route i.e. the VariationMarginComponent
tab2 -> <router-outlet name='futuresMargin'></router-outlet>
In futures-margin.routing.module.ts
. 在
futures-margin.routing.module.ts
。 I am not using this component as a standalone route so not sure if this matters. 我没有将此组件用作独立路由,因此不确定是否重要。
const routes: Routes = [{
path: AppSettings.FuturesMarginRoute,
component: FuturesMarginComponent,
canActivate: [AuthGuard],
outlet: 'futuresMargin'
}];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class FuturesMarginRoutingModule { }
However nothing is showing up for futuresMargin
in tab2
. 但是
tab2
futuresMargin
没有任何显示。 I see just he the blank tab. 我只看到他空白标签。
How should I configure the route for it to show up in the tab2
? 我应该如何配置路由使其显示在
tab2
?
事实证明,解决方案要简单得多,而且路由器链接必须好像它甚至不知道辅助路由一样
<a class="list" routerLink='variationMargin routerLinkActive="router-link-active">Projected VM</a>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.