import { ChangeDetectionStrategy , Component , Inject } from '@angular/core' ; import { MAT_DIALOG_DATA , MatDialogRef } from '@angular/material/dialog' ; @ Component ( { selector : 'app-confirm' , templateUrl : './confirm.component.html' , changeDetection : ChangeDetectionStrategy . OnPush } ) export class ConfirmComponent { message : string = 'Are you sure?' ; confirmButtonText = 'Yes' ; cancelButtonText = 'Cancel' ; constructor ( @ Inject ( MAT_DIALOG_DATA ) private data , private dialogRef ) { if ( data ) { this . message = data . message || this . message ; if ( data . buttonText ) { this . confirmButtonText = data . buttonText . ok || this . confirmButtonText ; this . cancelButtonText = data . buttonText . cancel || this . cancelButtonText ; } } } onConfirmClick ( ) { this . dialogRef . close ( true ) ; } }