我正在尝试使用Nebular
组件在 Agnular6 上创建一个 Web 对话框。有两种方法可以做到这一点,第一种是传递<ng-template>
引用,例如:
openAddDialog = (dialogTemplate: TemplateRef<any>) => {
this.dialogServiceRef = this.dialogService.open(dialogTemplate);
}
它运行良好。但我需要将组件作为参数传递,例如:
dialogService.open(MyComponent);
我的应用程序中有这个结构:
|_ 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
我已将,添加ModalFormComponent
到共享模块中。另外,我将它导入到 SearchBar 组件中,并在单击 searchBar 中的按钮时运行此函数:declarations
exports
entryComponents
openAddDialog = () => {
this.dialogServiceRef = this.dialogService.open(ModalFormComponent);
}
我在浏览器控制台中收到此错误:
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)
关于问题是什么以及如何解决它的任何想法?