Ramco Ramco

Ramco Ramco

  • 442
  • 3.4k
  • 515.7k

Confirmation Modal

Jun 6 2024 5:18 AM

Hi

  I have below Layout Component code. In Dialog Component HTMl i have delete function. Where i need to define & how to delete the record

export class LayoutComponent implements OnInit {
  

  constructor(private _dialog:MatDialog, private dialog: MatDialog){}
  openAddEditForm(){
    this._dialog.open(EmpAddEditComponent)
  }
  ngOnInit(): void {
    this.getallEmployee();
  }

  

  openConfirmationDialog(): void {
    const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
      width: '250px',
      data: { message: 'Are you sure you want to delete?' }
    });
  
    dialogRef.afterClosed().subscribe(result => {
      if (result) {
        // Perform delete action here
      }
    });
  }
   
}
<div mat-dialog-title>
    <h4> {{title}} </h4> 
</div>

<mat-dialog-content>
    <h5> {{message}} </h5> 
</mat-dialog-content>

<mat-dialog-actions>
    <button mat-raised-button color="warning" >Cancel</button>
    <button mat-raised-button color="primary" (click)="Delete()" type="submit">Delete</button>
</mat-dialog-actions>

 


Answers (3)