在这里,我想在basic
的初始加载中加载sidenav
的{{1}}页。
这是sidenav
,它将加载sidenav
routing.ts
但是它将给出此错误
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { MapGuard } from 'src/app/shared/guards/map.guard';
import { CampaignReportsComponent } from './campaign-reports.component';
const routes: Routes = [
{
path: '',
component: CampaignReportsComponent,
data: { breadcrumb: 'Campaign-report' },
redirectTo:'/basic',
children: [
{
path: 'type',
loadChildren:
'./campaign-reports-type/campaign-reports-type.module#CampaignReportsTypeModule',
canActivate: [MapGuard],
data: { breadcrumb: 'Type' }
},
{
path: 'basic',
loadChildren:
'./campaign-reports-basic/campaign-reports-basic.module#CampaignReportsBasicModule',
data: { breadcrumb: 'Basic' }
},
{
path: 'activity',
loadChildren:
'./campaign-reports-activity/campaign-reports-activity.module#CampaignReportsActivityModule',
data: { breadcrumb: 'Activity' }
},
{
path: 'rewards',
loadChildren:
'./campaign-reports-rewards/campaign-reports-rewards.module#CampaignReportsRewardsModule',
data: { breadcrumb: 'Rewards' }
},
{
path: 'winners',
loadChildren:
'./campaign-reports-winners/campaign-reports-winners.module#CampaignReportsWinnersModule',
data: { breadcrumb: 'Winners' }
}
]
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class CampaignReportsRoutingModule {}
在这里应该做什么?..请帮助
答案 0 :(得分:1)
修改路线,尝试直接调用/ basic时,您需要在children数组之外编写或添加空白路径,该路径将重定向到basic
const routes: Routes = [
{
path: '',
component: CampaignReportsComponent,
data: { breadcrumb: 'Campaign-report' },
children: [
{
path: '',
redirectTo:'/basic',
},
{
path: 'type',
loadChildren:
'./campaign-reports-type/campaign-reports-type.module#CampaignReportsTypeModule',
canActivate: [MapGuard],
data: { breadcrumb: 'Type' }
},
{
path: 'basic',
loadChildren:
'./campaign-reports-basic/campaign-reports-basic.module#CampaignReportsBasicModule',
data: { breadcrumb: 'Basic' }
},
{
path: 'activity',
loadChildren:
'./campaign-reports-activity/campaign-reports-
activity.module#CampaignReportsActivityModule',
data: { breadcrumb: 'Activity' }
},
{
path: 'rewards',
loadChildren:
'./campaign-reports-rewards/campaign-reports-
rewards.module#CampaignReportsRewardsModule',
data: { breadcrumb: 'Rewards' }
},
{
path: 'winners',
loadChildren:
'./campaign-reports-winners/campaign-reports-winners.module#CampaignReportsWinnersModule',
data: { breadcrumb: 'Winners' }
}
]
}
];