Is there a way to dynamically create and show a component in an ngx-bootstrap's modal?
I attempted to declare the component in the entryComponents option of RegMktRiskHomeModule, but it did not work. Currently, I am only able to declare the ScenariosGraphComponent in the AppModule, similar to how it is done in RegMktRiskCommonModule.
Could this issue be linked to the fact that RegMktRiskHomeModule is imported in HomeModule, which is lazy-loaded by the application?
Below is a snippet of my code:
reg-mkt-risk-common.module.ts:
@NgModule({
declarations: [
ScenariosGraphComponent
],
entryComponents: [
ScenariosGraphComponent
],
exports: [
ScenariosGraphComponent
],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class RegMktRiskCommonModule { }
reg-mkt-risk-home.module.ts:
@NgModule({
declarations: [
RegulatoryMarketRiskHomeComponent,
OverviewGridComponent // <-- component that displays ScenariosGraphComponent in a modal
],
exports: [
RegulatoryMarketRiskHomeComponent
],
imports: [
// ...,
RegMktRiskCommonModule
],
providers: [
// ...
]
})
export class RegMktRiskHomeModule { }
And here is the error message I am encountering:
ERROR Error: No component factory found for ScenariosGraphComponent. Did you add it to @NgModule.entryComponents?
at noComponentFactoryError (core.js:9659)
at CodegenComponentFactoryResolver.push../node_modules/@angular/core/fesm5/core.js.CodegenComponentFactoryResolver.resolveComponentFactory (core.js:9697)
at ComponentLoader.push../node_modules/ngx-bootstrap/component-loader/fesm5/ngx-bootstrap-component-loader.js.ComponentLoader._getContentRef (ngx-bootstrap-component-loader.js:411)
at ComponentLoader.push../node_modules/ngx-bootstrap/component-loader/fesm5/ngx-bootstrap-component-loader.js.ComponentLoader.show (ngx-bootstrap-component-loader.js:152)
at BsModalService.push../node_modules/ngx-bootstrap/modal/fesm5/ngx-bootstrap-modal.js.BsModalService._showModal (ngx-bootstrap-modal.js:927)
at BsModalService.push../node_modules/ngx-bootstrap/modal/fesm5/ngx-bootstrap-modal.js.BsModalService.show (ngx-bootstrap-modal.js:853)
at Object.action (overview-grid.options.ts:48)
at MenuItemComponent.push../node_modules/ag-grid-enterprise/dist/lib/menu/menuItemComponent.js.MenuItemComponent.onOptionSelected (menuItemComponent.js:102)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421)
at Object.onInvokeTask (core.js:16147)