我正在使用材料2版本2.0.0-beta.12.我需要调整材质Modal的位置.我按照这个答案来做到这一点./sf/answers/3096708961/由于MdDialog现在不可用,我使用了{MatDialog,MatDialogRef,MAT_DIALOG_DATA}.
constructor(public dialog: MatDialog,public dialModRef:MatDialogRef<any>) {}
Run Code Online (Sandbox Code Playgroud)
当我将MatDialogRef添加到我的构造函数时,它给了我"没有MatDialogRef的提供程序"错误.请你帮我解决这个问题吗?
对话框的概述,example.ts
import {Component, Inject} from '@angular/core';
import {MatDialog, MatDialogRef, MAT_DIALOG_DATA} from
'@angular/material';
@Component({
selector: 'dialog-overview-example',
templateUrl: 'dialog-overview-example.html'
})
export class DialogOverviewExample {
animal: string;
name: string;
constructor(public dialog: MatDialog,public
dialModRef:MatDialogRef<any>) {}
openDialog(): void {
let dialogRef = this.dialog.open(DialogOverviewExampleDialog, {
width: '500px',
data: { name: this.name, animal: this.animal }
});
dialogRef.afterClosed().subscribe(result => {
console.log('The dialog was closed');
this.animal = result;
});
}
}
@Component({
selector: 'dialog-overview-example-dialog',
templateUrl: 'dialog-overview-example-dialog.html',
})
export class DialogOverviewExampleDialog …Run Code Online (Sandbox Code Playgroud)