我一直在尝试使用太多方法并坚持使用新方案
下面的是我的app.module.ts
export const ROUTES: Routes=[
{
path: '', component: LoginComponent},
{
path: 'maincontent',
loadChildren: './main-content/maincontent.module#MainContentModule'
}]
下面的是我的maincontent.module.ts
export const ROUTES: Routes = [
{
path: 'maincontent',
component: MainContentComponent,
children: [
{ path: 'dashboard',
loadChildren: './dashboard/dashboard.module#DashboardModule' },
]
}];
在dashboard.module.ts中,我有以下路线
export const ROUTES: Routes = [
{
path:'dashboard', component:DashboardComponent,
children:[
{
path:'application',component:ApplicationDetailsComponent
}
]
}
]
问题是当我登录时,我已直接导航到仪表板页面,并且它没有显示页面的任何内容。我哪里出错可以有人指导我
答案 0 :(得分:1)
我正在经历类似的事情,但事实证明,我错过了依赖...
在你的情况下,@ yuzui的回答是正确的。
答案 1 :(得分:0)
我认为您应该将子路由的path
设为空字符串
<强> maincontent.module.ts 强>
export const ROUTES: Routes = [
{
path: '', // instead of path: 'maincontent',
component: MainContentComponent,
children: [
{
path: 'dashboard',
loadChildren: './dashboard/dashboard.module#DashboardModule'
},
]
}];
<强> dashboard.module.ts 强>
export const ROUTES: Routes = [
{
path: '', // instead of path: 'dashboard'
component: DashboardComponent,
children: [
{
path: 'application', component: ApplicationDetailsComponent
}
]
}
]
<强> Plunker Example 强>