1

Problem

i am using ngx-Bootstrap from valor-software I want to open a modal by clicking a button in header component and pass NewEmailComponent that is located inside Email Module(LazyLoaded ) to its parameter as template

Template

<button (click)="openNewEmailInModal()">contact us </button>

code in ts file

openNewEmailInModal(){
    this.bsModalService.show(NewEmailComponent,{class:'modal-md'});
}

But I get The Error

Error

No component factory found for NewEmailComponent . Did you add it to @NgModule.entryComponents?

current Set Up

But I have already Added it to the entryComponents of EmailModule.

Question?

so how can I access entryComponents of Lazyloaded modules when I need it.

What cant considered as solution

obviously moving NewEmaiComponetent to App Module is not the solution , because the application is big enough and mature, so moving it to require much refactoring.

Arash
  • 3,458
  • 7
  • 32
  • 50
  • What structure does your project have? I mean, where do you import ModalModule, EmailModule etc? – IlyaSurmay Nov 20 '17 at 11:11
  • they are both imported in app module which is the root module of my application – Arash Nov 20 '17 at 11:14
  • Could you create a reproduction? I tested it locally using latest version and it works fine. Starter templates for ngx-bootstrap project: Plunkr: https://plnkr.co/edit/0NipkZrnckZZROAcnjzB?p=preview StackBlitz: https://stackblitz.com/edit/ngx-bootstrap?file=app%2Fapp.module.ts – IlyaSurmay Nov 20 '17 at 12:09
  • the problem is Lazyloaded Module, they have their own injector and components defined in entryComponents are only available to the module not outside it. solutions you have provided is a single component and single module, if you have two module and one of them is lazy loaded then you will encounter error – Arash Nov 20 '17 at 12:15
  • Please create github repository with minimal reproduction. – IlyaSurmay Nov 20 '17 at 12:41

0 Answers0