我试着用带模块的路线..。
app.module
{
path: '',
component: AppComponent,
children: [
{ path: '', redirectTo: 'dashboard', pathMatch: 'full' },
{ path: 'dashboard', loadChildren: 'app/dashboard/dashboard.module#DashboardModule'
]
}使用导入RouterModule.forRoot(appRoutes)
dashboard.module
{
path: '',
component: DashboardComponent,
children: [
{ path: '', redirectTo: 'conta', pathMatch: 'full' },
{ path: 'conta', loadChildren: 'app/dashboard/conta/conta.module#ContaModule' }
]
}使用导入RouterModule.forChild(dashboardRoutes)
conta.module
{
path: '',
component: ContaComponent,
children: [
{ path: '', redirectTo: 'list', pathMatch: 'full' },
{ path: 'list', component: ContaListComponent }
]
}使用导入RouterModule.forChild(contaRoutes)
这样做的目的是:
当我运行这段代码时,应用程序加载的是App > Conta > ContaList,而不是App > Dashboard > Conta > ContaList。
我有我的模板(应用程序,仪表板和Conta)路由器插座.
我做错了什么?
发布于 2017-06-02 12:17:47
在仪表板组件中,您需要在conta模块中将路径指定为与仪表板相同的路径。
{
path: 'dashboard',
component: DashboardComponent,
children: [
{ path: '', redirectTo: 'conta', pathMatch: 'full' },
{ path: 'conta', loadChildren: 'app/dashboard/conta/conta.module#ContaModule' }
]
}
{
path: 'conta',
component: ContaComponent,
children: [
{ path: '', redirectTo: 'list', pathMatch: 'full' },
{ path: 'list', component: ContaListComponent }
]
}https://stackoverflow.com/questions/44328608
复制相似问题