Открытие диалогового окна Nebular из компонента окна Nebular

Моя структура такая:

|_ 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-delete-dialog на компоненте org-tree-component, он открывается нормально, поэтому я предполагаю, что это как-то связано с компонентом Window, открывающим компонент Dialog.

Что мне нужно добавить, чтобы это работало?

Спасибо.


person EricP    schedule 06.01.2020    source источник


Ответы (1)


Я изменил код так, что нажатие кнопки в любом месте просто отправляет событие, и это событие обрабатывается в компоненте org-tree-component, чтобы открыть фактический диалог.

person EricP    schedule 15.01.2020