how to open Md-dialog full screen angular4?
Asked Answered
C

3

29

I am trying to pass some property value using config. But dialog not open into full screen.

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

How can I open dialog full screen based on resolution?

Comp answered 28/3, 2018 at 9:58 Comment(0)
C
24

You can add a panelClass to the dialog and then apply whatever css just to that specific dialog.

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);
}

Create class:

.full-screen-modal .mat-dialog-container {
  max-width: none;
}
Cronk answered 28/3, 2018 at 10:17 Comment(1)
This code worked for me with maxWidth Set to 95vw dialogConfig = { position: { top: '10px', right: '10px' }, height: '98%', width: '100vw', maxWidth: '95vw', panelClass: 'full-screen-modal' }; Mammon
P
50

This work for me

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

Source

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

Pettifog answered 23/10, 2018 at 9:41 Comment(2)
Actually this solution puts the dialog completely fullscreen.Spraddle
Thanks, this is the simpliest solution.Yelena
C
24

You can add a panelClass to the dialog and then apply whatever css just to that specific dialog.

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);
}

Create class:

.full-screen-modal .mat-dialog-container {
  max-width: none;
}
Cronk answered 28/3, 2018 at 10:17 Comment(1)
This code worked for me with maxWidth Set to 95vw dialogConfig = { position: { top: '10px', right: '10px' }, height: '98%', width: '100vw', maxWidth: '95vw', panelClass: 'full-screen-modal' }; Mammon
J
7

This works for me:

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

style sheet:

.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;
    }
  }
}
Jacquez answered 20/5, 2020 at 6:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.