I created a products folder which contains products-home.component(parent) and products-list.component(child) with named outlet.
I get Error: Cannot match any routes. URL Segment: 'products'
when navigated to products-list
using lazy load.
This is working when it is eagerly loaded
app.module.ts
@NgModule({
imports: [ ...,ProductsModule ]
})
products.module.ts
@NgModule({
imports: [
RouterModule.forRoot([
{
path: "products",
component: ProductsHomeComponent,
children: [
{
path: "products-list",
component: ProductsComponent,
outlet: "content"
}
]
}
])
]
})
This is not working when it is lazy loaded
app.module.ts
const LazyRoutes: Routes = [
{
path: 'products',
loadChildren: './products/products.module#ProductsModule'
}
];
@NgModule({
imports: [ RouterModule.forRoot(LazyRoutes) ]
})
products.module.ts
@NgModule({
imports: [
RouterModule.forChild([
{
path: "",
component: ProductsHomeComponent,
children: [
{
path: "products-list",
component: ProductsComponent,
outlet: "content"
}
]
}
])
]
})