2

Any idea how to set the position of an MdDialog?

  openDialog() {
let config = new MdDialogConfig();
config.height = '15px';
config.position.left = '5px';
let dialogRef = this.dialog.open(BasicAlertDialog, config);
dialogRef.componentInstance.title = this.dialogTitle ;
dialogRef.componentInstance.text = this.dialogText ;
dialogRef.componentInstance.yes = this.dialogYes ;
dialogRef.componentInstance.no = this.dialogNo ;

I can set the height, but setting the position results in the error "ERROR TypeError: Cannot set property 'left' of undefined at AppComponent.webpackJsonp.267.AppComponent.openDialog (app.component.ts:385)". Line 385 is where I try to set the left position to 5px.

Hyerman
  • 31
  • 2
  • 1
    Possible duplicate of [Angular 2 Material. Dialog box not showing in the middle](https://stackoverflow.com/questions/41414964/angular-2-material-dialog-box-not-showing-in-the-middle) – Amit kumar Jun 07 '17 at 05:50

2 Answers2

0

you can set like that. does this help!

    openDialog() {
       let config = new MdDialogConfig();

       config.height = '15px';
       config.position = {
                left: '5px'
            };
       let dialogRef = this.dialog.open(BasicAlertDialog, config);
       dialogRef.componentInstance.title = this.dialogTitle ;
       dialogRef.componentInstance.text = this.dialogText ;
       dialogRef.componentInstance.yes = this.dialogYes ;
       dialogRef.componentInstance.no = this.dialogNo ;
   }
Shailesh Ladumor
  • 7,052
  • 5
  • 42
  • 55
0

From my working PoC:

  const dialogConfig = new MdDialogConfig();
  dialogConfig.position = { left: '20px' };
  dialog.open(PocModalComponent, dialogConfig);
Paul Lockwood
  • 4,283
  • 1
  • 24
  • 19