2017-06-07 2 views
2

Gibt es eine Idee, wie Sie die Position eines MdDialogs festlegen?Kann die Position des Dialogfelds Angular Material 2 mit MdDialogConfig nicht festlegen

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 ; 

kann ich die Höhe eingestellt, aber die Position führt zu dem Fehler „ERROR Typeerror Einstellung: Kann nicht gesetzt Eigenschaft‚links‘undefinierter bei AppComponent.webpackJsonp.267.AppComponent.openDialog (app.component.ts : 385) ". In Zeile 385 versuche ich, die linke Position auf 5px zu setzen.

+1

Mögliche Duplikat [Angular 2 Material. Das Dialogfeld wird nicht in der Mitte angezeigt] (https://stackoverflow.com/questions/41414964/angular-2-material-dialog-box-not-showing-in-the-middle) –

Antwort

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 ; 
    } 
+1

Ja. Das funktioniert. Vielen Dank! (Ich schwöre, ich habe das früher versucht. Na ja.) – Hyerman

0

Aus meiner Arbeits PoC:

const dialogConfig = new MdDialogConfig(); 
    dialogConfig.position = { left: '20px' }; 
    dialog.open(PocModalComponent, dialogConfig); 
Verwandte Themen