从 Nebular window 组件打开 Nebular 对话框
Opening Nebular dialog from Nebular window component
我的结构是这样的:
|_ app.module.ts
|_ app.component.ts
|_ admin
| |_ admin.module.ts
| |_ admin.component.ts
| |_ admin.component.html
| |_ org-tree
| |_ org-tree.component.ts
| |_ org-tree.component.html
| |_ org-edit
| |_ org-edit.component.ts
| |_ org-edit.component.html
| |_ org-delete-dialog
| |_ org-delete-dialog.component.ts
| |_ org-delete-dialog.component.html
org-tree 显示组织的分层列表。点击其中任何一个通过
打开编辑对话框
this.windowService.open(OrgEditComponent, { title: `Edit`, context: { organisation: org } });
此 window 包含一个带有保存和删除按钮的表单。删除按钮附在下面:
this.dialogService.open(OrgDeleteDialogComponent, {
context: {
organisation: this.organisation
},
closeOnBackdropClick: false,
});
单击此按钮出现以下错误:
ERROR Error: No component factory found for OrgDeleteDialogComponent. Did you add it to @NgModule.entryComponents? OrgEditComponent.html:138
at noComponentFactoryError (core.js:19453)
at CodegenComponentFactoryResolver.resolveComponentFactory (core.js:19504)
at NbPortalOutletDirective.attachComponentPortal (portal.js:506)
at NbDialogContainerComponent.attachComponentPortal (index.js:17947)
at NbDialogService.createContent (index.js:18156)
at NbDialogService.open (index.js:18114)
at OrganisationEditComponent.confirmDeleteOrg (organisations-edit.component.ts:43)
at Object.eval [as handleEvent] (OrganisationEditComponent.html:141)
at handleEvent (core.js:34777)
at callWithDebugContext (core.js:36395)
AdminModule 是:
@NgModule({
imports: [
CommonModule,
FormsModule,
NbCardModule,
ThemeModule,
NbTreeGridModule,
NbButtonModule,
NbInputModule,
NbIconModule,
NbWindowModule.forChild(),
NbDialogModule.forChild(),
],
declarations: [
AdminComponent,
OrgTreeComponent,
OrgDeleteDialogComponent,
OrgEditComponent,
FsIconComponent,
],
entryComponents: [
OrgDeleteDialogComponent,
OrgEditComponent,
]
})
export class AdminModule { }
如果我在 org-tree-component 上放置一个按钮来打开 org-delete-dialog,它可以正常打开,所以我猜这与 Window 组件打开 Dialog 组件有关。
我需要添加什么才能使这项工作正常进行?
谢谢。
我更改了代码,以便在任一位置单击按钮简单地调度一个事件,并且该事件在 org-tree-component 中处理以打开实际对话框。
我的结构是这样的:
|_ app.module.ts
|_ app.component.ts
|_ admin
| |_ admin.module.ts
| |_ admin.component.ts
| |_ admin.component.html
| |_ org-tree
| |_ org-tree.component.ts
| |_ org-tree.component.html
| |_ org-edit
| |_ org-edit.component.ts
| |_ org-edit.component.html
| |_ org-delete-dialog
| |_ org-delete-dialog.component.ts
| |_ org-delete-dialog.component.html
org-tree 显示组织的分层列表。点击其中任何一个通过
打开编辑对话框this.windowService.open(OrgEditComponent, { title: `Edit`, context: { organisation: org } });
此 window 包含一个带有保存和删除按钮的表单。删除按钮附在下面:
this.dialogService.open(OrgDeleteDialogComponent, {
context: {
organisation: this.organisation
},
closeOnBackdropClick: false,
});
单击此按钮出现以下错误:
ERROR Error: No component factory found for OrgDeleteDialogComponent. Did you add it to @NgModule.entryComponents? OrgEditComponent.html:138
at noComponentFactoryError (core.js:19453)
at CodegenComponentFactoryResolver.resolveComponentFactory (core.js:19504)
at NbPortalOutletDirective.attachComponentPortal (portal.js:506)
at NbDialogContainerComponent.attachComponentPortal (index.js:17947)
at NbDialogService.createContent (index.js:18156)
at NbDialogService.open (index.js:18114)
at OrganisationEditComponent.confirmDeleteOrg (organisations-edit.component.ts:43)
at Object.eval [as handleEvent] (OrganisationEditComponent.html:141)
at handleEvent (core.js:34777)
at callWithDebugContext (core.js:36395)
AdminModule 是:
@NgModule({
imports: [
CommonModule,
FormsModule,
NbCardModule,
ThemeModule,
NbTreeGridModule,
NbButtonModule,
NbInputModule,
NbIconModule,
NbWindowModule.forChild(),
NbDialogModule.forChild(),
],
declarations: [
AdminComponent,
OrgTreeComponent,
OrgDeleteDialogComponent,
OrgEditComponent,
FsIconComponent,
],
entryComponents: [
OrgDeleteDialogComponent,
OrgEditComponent,
]
})
export class AdminModule { }
如果我在 org-tree-component 上放置一个按钮来打开 org-delete-dialog,它可以正常打开,所以我猜这与 Window 组件打开 Dialog 组件有关。
我需要添加什么才能使这项工作正常进行?
谢谢。
我更改了代码,以便在任一位置单击按钮简单地调度一个事件,并且该事件在 org-tree-component 中处理以打开实际对话框。