I\'m trying to use an auxuliary router-outlet inside the primary router-outlet.
app.routing
export const appRoutes: Routes = [
{
I tried work with lazy loading and named router-outlets and found the following facts:
''. They won't work as children of empty path route. It may be fixed soon.<router-outlet> and its children would be auxiliary routes and other child routes. (It may be fixed soon, same as point 1.)you can load the named outlet by: url (parentRoute/outletName:['outletPath', param]), or using Router Link directive([routerLink]=['parentRoutes',{outlets: {outletName:['outletPath', param]}}], or programatically (this.router.navigate(['parentRoutes',{outlets: {outletName:['outletPath', param]}}])
To remove a named outlet, specify outlets: {outletName: null} in url, routerLink or code.
Due to a bug(redirect empty path child to named route does not work), there is currently no elegant way to load a named route by default and be able to later remove it with the above method. It may be fixed soon. However, you could have an empty path with a dummy component and in its constructor, you navigate to a URL that loads the default named route. Or you could do it in the parent component.
Special thanks to Brandon
I resolved using this route configuration:
RouterModule.forChild([
{
path: 'wrap',
component: PageComponent,
children: [
{
path: 'auxpath',
component: AuxComponent,
outlet: 'auxoutlet'
}
]
},
{
path: '',
component: PageComponent
}
])
This URL works:
/page/wrap/(auxoutlet:auxpath)