I have a route / component that requires a route parameter and has a named outlet. I want to lazy load a module and activate this route. Here are my routes:
Profile Module (sub module) Routes:
const routes: Routes = [
{
path: ':id', component: ProfileComponent
children: [
{ path: 'list/:id', component: ListComponent, outlet: 'sidebar' },
{ path: 'risk/:id', component: RiskComponent, outlet: 'sidebar' }
],
];
Parent Module Routes
const routes: Routes = [
{ path: 'projects/profile',
loadChildren: './profile/profile.module#ProfileModule' }
]
Loading the route results in the error:
Error: Cannot match any routes. URL Segment: 'projects/profile/-3'
When I use an empty string for the path in the sub module, there is no error and the module loads but the component doesn't load. I found this help with lazy loading route params and this help with lazy loading named router outlets, but neither worked.
My question is: How do I lazy load a route with a route parameter and named router outlet?
--Edit--
Here is a demo app that shows my problem. I created 3 main routes: one that lazy loads a submodule without named outlets, one the that lazy loads with a named outlet, and one that doesn't use lazy loading. In the UI, the link to the route that has a named outlet produces the error above.