1

I'm trying to load components dynamically in modal.

I've added my dynamic components in app-module entryComponents:

@NgModule({
imports: [
myDynamicComponent
],
entryComponents: [
    myDynamicComponent]
})


and I'm calling component so
const componentFactory =
      this.componentFactoryResolver.resolveComponentFactory(AppConstants.dynamicComponents['AComponentType']); 
    let options: NgbModalOptions = { size: 'xl' };
    let modalRef = this.characteristicsModal.open(componentFactory, options);

I get error No component factory found for [object Object]. Did you add it to @NgModule.entryComponents?

TamKap
  • 139
  • 3
  • 9
  • Why are you doing that? NgbModal does that for you. You just pass the type of a component, and it instantiates it and puts it in a modal for you. https://ng-bootstrap.github.io/#/components/modal/examples#component. Bsides, `imports` is used to import modules, not components. Components go to declarations, not imports. – JB Nizet Aug 31 '19 at 07:12
  • because in real case my component name comes from user selected value. – TamKap Sep 02 '19 at 07:55
  • Does this answer your question? [Angular 4: no component factory found,did you add it to @NgModule.entryComponents?](https://stackoverflow.com/questions/46990389/angular-4-no-component-factory-found-did-you-add-it-to-ngmodule-entrycomponent) – canbax Nov 25 '19 at 06:26

0 Answers0