I have a complete angular app that uses eager loading. I want to convert it to lazy loading, but because I have guard on all of my routes and all of them are sub routes to one main route that is guarded, I don't know if it's possible to do it and still make it function like with eager loading.
This is my routing array in app-routing.module:
// Routing array - set routes to each html page
const appRoutes: Routes = [
{ path: 'login/:id', canActivate: [AuthGuard], children: [] },
{ path: '', canActivateChild: [AuthGuard], children: [
{ path: '', redirectTo: '/courses', pathMatch: 'full' },
{ path: 'courses', component: CourseListComponent, pathMatch: 'full'},
{ path: 'courses/:courseId', component: CourseDetailComponent, pathMatch: 'full' },
{ path: 'courses/:courseId/unit/:unitId', component: CoursePlayComponent,
children: [
{ path: '', component: CourseListComponent },
{ path: 'lesson/:lessonId', component: CourseLessonComponent, data:{ type: 'lesson'} },
{ path: 'quiz/:quizId', component: CourseQuizComponent, data: {type: 'quiz'} }
]}
]},
{ path: 'welcome', component: LandingPageComponent, pathMatch: 'full' },
{ path: '**', component: PageNotFoundComponent, pathMatch: 'full' }];
What I want to know is if it's possible to implement this with lazy loading and if so I'd like to know the main idea or what I need to know in order to do that.
In all the tutorials I did I never encounter this kind of thing. Thank you very much