繁体   English   中英

angular-自定义MatDialogConfig文件的输入

[英]angular - input for a custom MatDialogConfig file

因此,我为所有材质对话框创建了一个自定义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";

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM