My current project involves creating a web dialog in Angular6 using Nebular components. Initially, I used the method of passing an <ng-template>
reference in the following manner:
openAddDialog = (dialogTemplate: TemplateRef<any>) => {
this.dialogServiceRef = this.dialogService.open(dialogTemplate);
}
This approach worked without any issues. However, I now need to pass a component as a parameter like so:
dialogService.open(MyComponent);
My project structure is organized as follows:
|_ pages
| |_ pages.module.ts
| |_ patient
| |_ patient.module.ts
| |_ patient.component.ts
| |_ patient.component.html
|
|_ shared
|_ shared.module.ts
|_ components
| |_ search-bar.component.ts
| |_ search-bar.component.html
|
|_ modal-form
|_ modal-form.component.ts
|_ modal-from.component.html
I have added the ModalFormComponent
to the declarations
, exports
, and entryComponents
in the shared module. Additionally, I imported it in the SearchBar component and attempted to run the function upon clicking a button in the searchBar:
openAddDialog = () => {
this.dialogServiceRef = this.dialogService.open(ModalFormComponent);
}
Upon testing, I encountered the following error in the browser console:
ERROR Error: No component factory found for ModalFormComponent. Did you add it to @NgModule.entryComponents?
at noComponentFactoryError (core.js:19453)
at CodegenComponentFactoryResolver.resolveComponentFactory (core.js:19504)
at NbPortalOutletDirective.attachComponentPortal (portal.js:506)
at NbDialogContainerComponent.attachComponentPortal (index.js:17128)
at NbDialogService.createContent (index.js:17336)
at NbDialogService.open (index.js:17295)
at SearchBarComponent.openAddDialog (search-bar.component.ts:46)
at Object.eval [as handleEvent] (SearchBarComponent.html:11)
at handleEvent (core.js:34777)
at callWithDebugContext (core.js:36395)
Do you have any insights on what might be causing this issue and how I can resolve it?