我为对话框系统工作(角材料)。
我为控件和容器对话框创建对话框服务。对话框服务具有用于打开/显示不同对话框的方法。
并且我创建对话框组件以包含对话框的数据(它是对话框的单个组件)。它是通用组件。
我添加了StackBlitz(但是它发疯了,并且文件路径存在问题;我将尝试修复它)
我在回调后关闭对话框时遇到问题。回调后如何关闭对话框?我尝试使用[mat-dialog-close]-但无法以某种方式进行参数设置-启用和禁用不同按钮的[mat-dialog-close]。
还有一点点问题。如何动态地将mat-button添加到按钮元素?
((我添加了'mat-button'类,但是没有完全模仿mat-button)
<div *ngIf="getButtons().length > 0 || getCloseButton()" mat-dialog-actions>
<ng-container *ngFor="let button of getButtons()">
<button [attr.class]="button.class"
(click)="button.callback(button.callbackItem || dialogForm)">{{button.title}}</button>
</ng-container>
</div>
在您的dialog.html中,您必须具有以下内容:
<button mat-stroked-button (click)="closeDialog()">Close</button>
以及在您的dialog.ts中:
import { Component, OnInit, Inject } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';
@Component({
selector: 'dialog',
templateUrl: './dialog.component.html',
styleUrls: ['./dialog.component.scss']
})
export class DialogComponent implements OnInit {
constructor(public dialogRef: MatDialogRef<DialogComponent>) { }
ngOnInit() {
}
closeDialog() {
this.dialogRef.close();
}
}