Angular4 router, Lazy loaded child route modules called routers
I have a strange question. I need to configure the secondary routers to be the root routing elements of my lazy loaded modules, which have url settings in the application routing module. The explanation seems a bit tricky, but I'll try to explain it.
My app routing has this
{
path: 'management',
loadChildren: 'app/management-tool/management-tool.module#ManagementToolModule',
canActivate: [AuthGuardService]
},
this means that all routes of the control tool must start with
/Control
Now in the management module, I need the main content to appear on the secondary router socket called "managementtoolcontent". For this I have 2 test routes, one of which works for me.
The management tool routing is as follows.
const routes: Routes = [
{
path: '',
component: ManagementToolComponent,
children: [
{
path: 'overview',
component: ManagementToolMarketingComponent,
outlet: 'managementtoolcontent'
},
{
path: 'products',
component: ManagementToolMarketingComponent,
outlet: 'managementtoolcontent'
}
]
},
{
path: 'test',
component: ManagementToolComponent,
children: [
{
path: 'overview',
component: ManagementToolMarketingComponent,
outlet: 'managementtoolcontent'
},
{
path: 'products',
component: ManagementToolMarketingComponent,
outlet: 'managementtoolcontent'
}
]
}
];
as you can see, the empty route "route" and "test" both have the same children. I also have a router output setup.
<router-outlet name="managementtoolcontent"></router-outlet>
What I think is the problem with the officer?
I need the route "/ management / overview" to open the ManagementToolMarketingComponent on my secondary outlet, but this routerLink is giving me an undefined route error
[routerLink]="['/management', {outlets: {managementtoolcontent: ['overview']}}]"
However, this work is totally beautiful.
[routerLink]="['/management/test', {outlets: {managementtoolcontent: ['overview']}}]"
My question is, why do I need to add an extra url segment ('/ test') to the mix so that I have secondary routers? What, gods, am I doing wrong here?
Are all fake loaded routes showing up on the secondary outlet? If so, you can try adding an output to the lazy loaded route config:
{
path: 'management',
loadChildren: 'app/management-tool/managementtool.module#ManagementToolModule',
canActivate: [AuthGuardService],
outlet: 'managementtoolcontent'
},