src/app/component/dialog/confirm/confirm.component.ts
| selector | stbui-dialog-confirm |
| styleUrls | ./confirm.component.scss |
| templateUrl | ./confirm.component.html |
Properties |
Methods |
constructor(dialogRef: MatDialogRef
|
||||||
|
Parameters :
|
| accept |
accept()
|
|
Returns :
void
|
| cancel |
cancel()
|
|
Returns :
void
|
| acceptButton |
Type : string
|
Default value : '确定'
|
| cancelButton |
Type : string
|
Default value : '取消'
|
| message |
Type : string
|
| title |
Type : string
|
import { Component } from '@angular/core';
import { MatDialogRef } from '@angular/material/dialog';
@Component({
selector: 'stbui-dialog-confirm',
templateUrl: './confirm.component.html',
styleUrls: ['./confirm.component.scss']
})
export class ConfirmComponent {
title: string;
message: string;
cancelButton: string = '取消';
acceptButton: string = '确定';
constructor(private dialogRef: MatDialogRef<ConfirmComponent>) {}
cancel(): void {
this.dialogRef.close(false);
}
accept(): void {
this.dialogRef.close(true);
}
}
<stbui-dialog>
<stbui-dialog-title *ngIf="title">
{{title}}
</stbui-dialog-title>
<stbui-dialog-content>
{{message}}
</stbui-dialog-content>
<stbui-dialog-actions>
<button mat-button #closeBtn (keydown.arrowright)="acceptBtn.focus()" (click)="cancel()">{{cancelButton}}</button>
<button mat-button #acceptBtn (keydown.arrowleft)="closeBtn.focus()" (click)="accept()" color="accent">{{acceptButton}}</button>
</stbui-dialog-actions>
</stbui-dialog>
./confirm.component.scss