jeudi 24 octobre 2019

Angular 8: Lazy Module with forRoot method

I have an angular module loaded lazy using the new angular 8 method:

loadChildren: () => import('path').then(module => module.MyModuleClass)

This works fine, but now i require to configure the module. Normally this is easily accieved by implementing a static forRoot() method that returns a ModuleWithProviders object. But if i call it like this:

loadChildren: () => import('path').then(module => module.MyModuleClass.forRoot(myConfig))

... then I get a runtime error Error: Uncaught (in promise): Error: No NgModule metadata found for '[object Object]'.

Is there a way to use a module configuration for lazy loaded modules?

Thanks!




Aucun commentaire:

Enregistrer un commentaire