知道如何设置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:无法设置属性'左'未定义 在AppComponent.webpackJsonp.267.AppComponent.openDialog(app.component.ts:385)“。第385行我尝试将左侧位置设置为5px。
答案 0 :(得分: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 ;
}
答案 1 :(得分:0)
从我的工作PoC:
const dialogConfig = new MdDialogConfig();
dialogConfig.position = { left: '20px' };
dialog.open(PocModalComponent, dialogConfig);