繁体   English   中英

系统对话框 Angular Material

[英]System dialog Angular Material

我为对话系统(Angular Material)工作。

我为控件和容器对话框创建了对话框服务。 Dialog-service 具有打开/显示不同对话框的方法。

我为包含对话框的数据创建了对话框组件(它是对话框的单个组件)。 它是通用组件。

我添加了StackBlitz

我在回调后关闭对话框时遇到问题。 回调后如何关闭对话框? 我尝试使用[mat-dialog-close] - 但我无法以某种方式参数化 - 启用和禁用不同按钮的[mat-dialog-close]

而且有点问题。 如何将动态垫按钮添加到按钮元素?

(我添加了“垫子按钮”类,但这不是完全模仿垫子按钮)

 <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();
  }

}

暂无
暂无

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

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