2

知道如何设置 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 ;

我可以设置高度,但设置位置会导致错误“ERROR TypeError: Cannot set property 'left' of undefined at AppComponent.webpackJsonp.267.AppComponent.openDialog (app.component.ts:385)”。第 385 行是我尝试将左侧位置设置为 5px 的位置。

4

2 回答 2

0

从我的工作 PoC 中:

  const dialogConfig = new MdDialogConfig();
  dialogConfig.position = { left: '20px' };
  dialog.open(PocModalComponent, dialogConfig);
于 2017-09-05T12:43:00.487 回答
0

你可以这样设置。这有帮助吗!

    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 ;
   }
于 2017-06-07T04:27:00.017 回答