可以使用对父容器的引用将其宽度和高度传递给openDialog()函数,以便与一起使用对话框.打开(). 例如:
<div #parent class="parent-container" fxLayout="row" fxLayoutAlign="center center" >
<button (click)="openDialog(parent.clientWidth, parent.clientHeight)" mat-button>
open dialog
</button>
</div>
openDialog(width, height) {
const dialog_ref = this.dialog.open(EntryComponent, {
width: width + 'px',
height: height + 'px'
});
dialog_ref.afterClosed().subscribe(result => {});
}