How to get Router config
for lazy loaded module routes in Angular 2 Router?
When I log config on router object, only available routes from the module which has already been loaded are logged,
export class AppComponent {
constructor(private router: Router){
console.log(router.config);
}
}
router config
I understand since routes inside Lazy loaded modules are resolved at runtime, hence the config are not available. But it restricts us to get configuration data.
Is there a way in which we may get Route data from within the lazy loaded module without loading the module? Or define all routes in start and load the modules lazily?
Thanks in advance!!
use preloadingStrategy.
RouterModule.forRoot(
appRoutes,
{
enableTracing: true, // <-- debugging purposes only
preloadingStrategy: PreloadAllModules
}
)