[英]System dialog Angular Material
I work for system of dialog (Angular Material).我为对话系统(Angular Material)工作。
I create dialog-service for controll and container dialog.我为控件和容器对话框创建了对话框服务。 Dialog-service has methods for open/show different dialoges.
Dialog-service 具有打开/显示不同对话框的方法。
And I create dialog-component for contain data for dialog (it is single component of dialog).我为包含对话框的数据创建了对话框组件(它是对话框的单个组件)。 It is universal component.
它是通用组件。
I add StackBlitz我添加了StackBlitz
I have problem with closing dialoges after callback.我在回调后关闭对话框时遇到问题。 How I can close dialog after callback?
回调后如何关闭对话框? I try using [mat-dialog-close] - but I was not able to somehow parameterize - enable and disable the [mat-dialog-close] of different buttons.
我尝试使用[mat-dialog-close] - 但我无法以某种方式参数化 - 启用和禁用不同按钮的[mat-dialog-close] 。
And a have little problem.而且有点问题。 How I can add dynamicly mat-button to button element?
如何将动态垫按钮添加到按钮元素?
(I add class 'mat-button', but this don't full imitation 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>
In your dialog.html you must have something like this:在你的 dialog.html 你必须有这样的东西:
<button mat-stroked-button (click)="closeDialog()">Close</button>
and in your dialog.ts:在你的 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.