I have a module 'DevicePreview' that have some routes and can be displayed both from root and from inside another module 'Content'.
When called from root DevicePreview has routes /a, /b and /c available, when called from Content it has /a, /b and /z.
Right now I'm exporting 2 arrays of routes like this (names are faked):
export const DEVICE_ROOT_ROUTES: Routes = [
{
path: 'a',
component: DeviceAComponent
}, {
path: 'b',
component: DeviceBComponent
}, {
path: 'c',
component: DeviceCComponent
}
];
export const DEVICE_CONTENT_ROUTES: Routes = [
{
path: 'a',
component: DeviceAComponent
}, {
path: 'b',
component: DeviceBComponent
}, {
path: 'z',
component: DeviceZComponent
}
];
Now I want to move this to lazy loaded module. AFAIK to lazy load modules I have to do this:
{
path: 'device',
loadChildren: 'app/+device/device.module#DeviceModule'
}
As I don't want to enable Z in root nor C in Component and neither generating 2 different modules I'm thinking of configuring DeviceModule when loading through a .forChild(options)
How could I call forChild when lazy loading? I may consider other approaches too.
Thanks!