我正在尝试使用Nebular组件在 Agnular6 上创建一个 Web 对话框。有两种方法可以做到这一点,第一种是传递<ng-template>引用,例如:
openAddDialog = (dialogTemplate: TemplateRef<any>) => {
this.dialogServiceRef = this.dialogService.open(dialogTemplate);
}
Run Code Online (Sandbox Code Playgroud)
它运行良好。但我需要的是将组件作为参数传递,例如:
dialogService.open(MyComponent);
Run Code Online (Sandbox Code Playgroud)
我的应用程序中有这个结构:
|_ 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
Run Code Online (Sandbox Code Playgroud)
我已经添加了ModalFormComponent到declarations,exports和entryComponents共享的模块中。此外,我将它导入到 SearchBar 组件中,并在单击 searchBar 中的按钮时运行此函数:
|_ pages
| |_ pages.module.ts
| |_ patient …Run Code Online (Sandbox Code Playgroud)