Angular4模态对话框问题

时间:2018-06-08 09:10:03

标签: angular internet-explorer-11

我正在使用Angular 4.我正在尝试使用ngx-modal-dialog在我的应用程序中弹出一个。

我正在使用IE11浏览器。以下是我的代码:

在ParentPageComponent.ts文件中,openNewDialog()函数定义如下:

openNewDialog(){
    this.modalService.openDialog
    (
        this.viewRef, 
        {
            title: 'Some modal title',childComponent: SimpleModalComponent
        }
    );
}

ParentPageComponent.ts文件的构造函数定义为

constructor(modalService: ModalDialogService, viewRef: ViewContainerRef){}

我在app.module.ts文件中添加了entryComponents

entryComponents:[SimpleModalComponent]

我从ParentPageComponent.html页面调用openNewDialog函数。

从父页面调用openNewDialog方法时,我无法弹出并出现以下错误。

  

TypeError:Object不支持属性或方法'dialogInit'

任何有关检测问题的帮助都会有很大帮助。

1 个答案:

答案 0 :(得分:0)

根据docs,您需要实施IModalDialog,并且需要在dialogInit中定义ModalComponent

从文档中检查此示例

class MyModalComponent implements IModalDialog {
  actionButtons: IModalDialogButton[];

  constructor() {
    this.actionButtons = [
      { text: 'Close' }, // no special processing here
      { text: 'I will always close', onAction: () => true },
      { text: 'I never close', onAction: () => false }
    ];
  }

  dialogInit(reference: ComponentRef<IModalDialog>, options: Partial<IModalDialogOptions<any>>) {
    // no processing needed
  }
}
相关问题