如何打开Md-dialog全屏angular4?

时间:2018-03-28 09:58:19

标签: angular angular-material2 mddialog

我正在尝试使用config传递一些属性值。但对话框无法全屏显示。

openTwigTemplate(): void {
  let config = new MdDialogConfig();
  config = {
    position: {
      top: '10px',
      right: '10px'
    },
    height: '98%',
    width: '100vw',
  };
  const dailog = this.dialog.open(TwigDialogComponent, config);
}

如何根据分辨率全屏打开对话框?

3 个答案:

答案 0 :(得分:5)

您可以在对话框中添加panelClass,然后将任何css应用于该特定对话框。

openTwigTemplate(): void {
  let config = new MdDialogConfig();
  config = {
    position: {
      top: '10px',
      right: '10px'
    },
    height: '98%',
    width: '100vw',
    panelClass: 'full-screen-modal',
  };
  const dailog = this.dialog.open(TwigDialogComponent, config);
}

创建课程:

.full-screen-modal .mat-dialog-container {
  max-width: none;
}

答案 1 :(得分:3)

这对我有用

let dialogRef = this.dialog.open(CustomerGarageAddEditComponent, {
      maxWidth: '100vw',
      maxHeight: '100vh',
      height: '100%',
      width: '100%'
    });

来源

https://github.com/angular/material2/issues/9823

答案 2 :(得分:2)

这对我有用:

openTwigTemplate(): void {
  const dialog = this.dialog.open(TwigDialogComponent, {
    disableClose: true,
    panelClass: ['full-screen-modal']
  });
}

样式表:

.full-screen-modal {
  max-width: unset !important;
  width: 100%;
  height: 100%;
  .mat-dialog-container {
    max-width: 100vw;
    max-height: 100vh;
    height: 100%;
    width: 100%;
    .mat-dialog-content {
      max-height: unset !important;
    }
  }
}