所以,我有一个用于所有材质对话框的自定义MaterialDialogConfig文件,如下所示:
import { MatDialogConfig } from "@angular/material";
export class MaterialDialogConfig extends MatDialogConfig {
constructor(data: any = {}, width: string = "720px") {
super();
this.data = data;
this.width = width;
this.hasBackdrop = true;
this.disableClose = true;
this.closeOnNavigation = true;
}
}
我的一个对话框组件如下所示:
constructor(
private service: AppService,
public dialogRef: MatDialogRef<DIALOGCOMPONENT>,
@Inject(MAT_DIALOG_DATA) public data: any
) {}
ngOnInit() {}
如何将width属性设置为所有单独对话框组件实例的输入?
结果证明是一个快速修复。只需将变量导出为常量:
import { MatDialogConfig } from "@angular/material";
export class MaterialDialogConfig extends MatDialogConfig {
constructor(data: any = {}, width: string = "720px") {
super();
this.data = data;
this.width = width;
this.hasBackdrop = true;
this.disableClose = true;
this.closeOnNavigation = true;
}
}
export const DIALOG_SMALL: string = "480px";
export const DIALOG_MID: string = "720px";
export const DIALOG_BIG: string = "1200px";
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句