I have some modules: "dashboard", "family" and "children". These modules are lazy loaded in my appRoute except for the "childen" module:
export const appRoutes: Routes = [
{ path: '', loadChildren: 'app/dashboard/dashboard.module#DashboardModule' },
{ path: 'family', loadChildren: 'app/family/family.module#FamilyModule' },
{
path: '404',
component: Error404PageComponent,
resolve: { data: Error404PageResolver }
},
{
path: '**',
component: Error404PageComponent,
resolve: { data: Error404PageResolver }
}
];
@NgModule({
imports: [ RouterModule.forRoot(appRoutes, {
preloadingStrategy: PreloadAllModules,
useHash: false
}) ],
exports: [ RouterModule ]
})
export class AppRoutingModule {}
My Family route file is like this:
const familyRoutes: Routes = [
{
path: '',
component: FamilyComponent
{
path: ':id',
component: FamilleComponent
];
@NgModule({
imports: [RouterModule.forChild(familyRoutes)],
exports: [RouterModule]
})
export class FamilyRoutingModule { }
And for my "children" module, it is almost the same thing except in the route, the first part of the route contains family route:
const childRoutes: Routes = [
{
path: 'family/:familyId/child',
component: ChildComponent
},
{
path: 'family/:familyId/child/:id',
component: ChildComponent
}
];
I would like to lazy load the "children" module but I don't know how to do it because this module is a child of the module "family". My issue is the route linked to child is not available. So the url http://localhost:4200/family/830503261/child/830581020 is not working.
I tried to add the line loadChildren in familyRoutes but is not working:
const familleRoutes: Routes = [
{
path: '',
component: FamilyComponent
{
path: ':id',
component: FamilyComponent,
loadChildren: './../child/child.module#ChildModule'
];
I don't know how to access to my children using path "family" in the route.
Any idea? Thanks.