I have the following routing configuration:
export const ROUTES: Routes = [
{ path: '',
component: MainComponent,
children: [
{
path: 'hero-video',
component: HeroOverlayComponent,
outlet: 'overlay'
}
]
}
];
export const appRouting = RouterModule.forRoot(ROUTES);
The idea is that I have one component who has an overlay routing outlet which shows different outlets on that main page. However that does not work, I always get the error that is no such route.
If I remove the outlet part (and of course also update the selector, everything works.
export const ROUTES: Routes = [
{ path: '',
component: MainComponent,
children: [
{
path: 'hero-video',
component: HeroOverlayComponent
}
]
}
];
export const appRouting = RouterModule.forRoot(ROUTES);
Do I miss something or why is the behaviour different if I use a named router outlet or not for root routes?
Route configuration looks fine. It seems that Angular has an issue with how you're exporting the router. I'd suggest changing how you're serving the
RouterModule.I'd create
AppRoutingModuleand then import it to mainAppModuleinstead of doing it your way.Then in your
app.module.ts