Javascript “系统”对话框“角度材质”

Javascript “系统”对话框“角度材质”,javascript,angular,button,angular-material,angular-material2,Javascript,Angular,Button,Angular Material,Angular Material2,我为dialog系统(角度材质)工作 我为控件和容器对话框创建对话框服务。对话框服务具有打开/显示不同对话框的方法 我为包含dialog数据创建了dialog组件(它是dialog的单个组件)。它是通用组件 我补充说 我在回调后关闭对话框时遇到问题。 如何在回调后关闭对话框?我尝试使用[mat dialog close]-但我无法以某种方式参数化-启用和禁用不同按钮的[mat dialog close] 还有一个小问题。如何向按钮元素动态添加按钮 (我添加了类“mat button”,但这不是完

我为dialog系统(角度材质)工作

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

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

我补充说

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

还有一个小问题。如何向按钮元素动态添加按钮

(我添加了类“mat button”,但这不是完全模仿mat button)


{{button.title}}

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

}
从'@angular/core'导入{Component,OnInit,Inject};
从“@angular/material”导入{MAT_DIALOG_DATA,MatDialogRef};
@组成部分({
选择器:“对话框”,
templateUrl:'./dialog.component.html',
样式URL:['./dialog.component.scss']
})
导出类DialogComponent实现OnInit{
构造函数(public dialogRef:MatDialogRef){}
恩戈尼尼特(){
}
closeDialog(){
this.dialogRef.close();
}
}

是的,这是个好主意,但我认为对话服务和对话组件之间的关系如何。我如何为对话框组件生成按钮数据,有人认为按钮在回调函数后关闭对话框?请看StackBlitz的例子。
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();
  }

}