lazy loading is not working with entryComponents

Bug description:

Following “Components as content” demo for modals is working fine. But if the component is in a submodule lazy loaded it is not working.

It says:
No component factory found for NgbdModalContent. Did you add it to @NgModule.entryComponents?

If the module is loaded in root AppModule its working fine.

I found a workaround:

  1. Import NgbModule.forRoot() should be in the loaded submodule, not in root module
  2. <template ngbModalContainer></template> should also be part of the submodule. Otherwise it says Error: No provider for NgbModal!

The problem is that i need only one instance of NgbModule inside of my root AppModule. Also the template should be part of root app.component.html. But then the factory is not found in the loaded submodule.

Additonally i found similiar issues at angular material2. They solved it by getting rid of forRoot() import (NgbModule.forRoot()). Im not sure if this helps.

Issues:
angular/components#2517
angular/components#1765

Version of Angular, ng-bootstrap, and Bootstrap:

latest

1 possible answer(s) on “lazy loading is not working with entryComponents