I am working on an Angular application that has lazy loading implemented. I tried experimenting with lazy loading but decided that I do not yet want to implement it in my application. This is my 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 { }
How can I switch my route to for example hq
back to normal loading? I expected that something as follows would work:
{ path: 'hq', redirectTo: HqModule }
That however returns that my module is a wrong type of argument. Is this even possible in Angular?
hq.module.ts
@NgModule({
imports: [
CommonModule,
RouterModule.forChild([
{ path: '',
component: HqTemplateComponent,
canActivate: [AuthGuard],
children: [
{ path: '', pathMatch: 'full', redirectTo: 'overview' },
{ path: 'overview', component: OverviewComponent, canActivate: [AuthGuard] },
]
},
]),
],
declarations: [HqTemplateComponent, OverviewComponent]
})