Rehan Khan
Rehan Khan

Reputation: 154

Angular 2+ Lazy Loading Child routes not working

My implementation is as follows:

App Routes :

export const AppRoutes: Routes = [
    {
    path: 'external',
    loadChildren: './_Layouts/external-layout/external-layout.module#ExternalLayoutModule'
  }]

external Routes:

export const ExternalRoutes: Routes = [
  { path: '', component: ExternalComponent, pathMatch: 'full', canActivate: [AuthGuard] },
  { path: 'programmes', component: ProgrammesComponent, canActivate: [AuthGuard] },
];

The issue is when the url is localhost:4200/external it works fine

But when it is localhost:4200/programmes OR localhost:4200/external/programmes

It is not working at all, What i am missing?

Thanks in advance!

Upvotes: 0

Views: 70

Answers (1)

Ollie
Ollie

Reputation: 36

Are you getting any sort of error? What version of Angular?

Also, I think in later versions the loadChildren syntax is as follows:

    loadChildren: () => import('./items/items.module').then(m => m.ItemsModule)

See more here: https://angular.io/guide/lazy-loading-ngmodules

Upvotes: 1

Related Questions