我正在开发一个实现了延迟加载的Angular应用程序.我试着尝试延迟加载,但我决定不想在我的应用程序中实现它.这是我的app.module.ts:
app.module.ts:
@NgModule({
declarations: [
AppComponent,
],
imports: [
BrowserModule,
RouterModule.forRoot([
{ path: '', redirectTo: 'store', pathMatch: 'full'},
{ path: 'hq', loadChildren: 'app/hq/hq.module#HqModule' },
{ path: 'store', loadChildren: 'app/store/store.module#StoreModule', pathMatch: 'prefix'},
]),
],
bootstrap: [AppComponent],
exports: [RouterModule],
})
export class AppModule { }
Run Code Online (Sandbox Code Playgroud)
如何切换路线,例如hq恢复正常加载?我期望以下内容可行:
{ path: 'hq', redirectTo: HqModule }
Run Code Online (Sandbox Code Playgroud)
然而,这会返回我的模块是一种错误的参数类型.这在Angular中甚至可能吗?
hq.module.ts
@NgModule({
imports: [
CommonModule,
RouterModule.forChild([
{ path: '',
component: HqTemplateComponent,
canActivate: [AuthGuard],
children: [
{ path: '', pathMatch: 'full', redirectTo: 'overview' },
{ …Run Code Online (Sandbox Code Playgroud)