英文:
Opening Nebular dialog from Nebular window component
问题
My structure is like this:
|_ 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 } });
此窗口包含一个带有保存和删除按钮的表单。删除按钮与以下内容相关联:
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组件有关。
我需要添加什么来使其正常工作?
谢谢。
英文:
My structure is like this:
|_ 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 displays a hierarchical list of organisations. Clicking on any of these opens the edit dialog via
this.windowService.open(OrgEditComponent, { title: `Edit`, context: { organisation: org } });
This window contains a form with a save and a delete button. The delete button is attached to the following:
this.dialogService.open(OrgDeleteDialogComponent, {
context: {
organisation: this.organisation
},
closeOnBackdropClick: false,
});
Clicking this button gives the following error:
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 is:
@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 { }
If I put a button to open the org-delete-dialog on the org-tree-component, it opens fine, so I guess it's something to do with the Window component opening the Dialog component.
What do I need to add to make this work?
Thanks.
答案1
得分: 0
我更改了代码,使得在任何位置点击按钮都会触发一个事件,然后该事件在org-tree-component中处理,以打开实际的对话框。
英文:
I changed the code so that clicking the button in either location simply dispatched an event, and that event was handled in the org-tree-component to open the actual dialog.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论