import {Component, ViewChild, TemplateRef} from '@angular/core'; import {MatDialog, MatDialogRef, MatDialogConfig} from '@angular/material/dialog'; @Component({ selector: 'dialog-e2e', moduleId: module.id, templateUrl: 'dialog-e2e.html' }) export class DialogE2E { dialogRef: MatDialogRef | null; @ViewChild(TemplateRef, {static: false}) templateRef: TemplateRef; constructor (private _dialog: MatDialog) { } private _openDialog(config?: MatDialogConfig) { this.dialogRef = this._dialog.open(TestDialog, config); this.dialogRef.afterClosed().subscribe(() => this.dialogRef = null); } openDefault() { this._openDialog(); } openDisabled() { this._openDialog({ disableClose: true }); } openTemplate() { this.dialogRef = this._dialog.open(this.templateRef); } } @Component({ selector: 'dialog-e2e-test', template: `

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

` }) export class TestDialog { constructor(public dialogRef: MatDialogRef) { } }