Jay
Jay

Reputation: 9477

angular - primeng - confirmdialog not working

Angular 7 - primeng - confirmdialog not working

HTML

<p>confirm-dialog</p>
<button type="button" (click)="confirm()" pButton icon="pi pi-check" label="Confirm"></button>

Typescript

  confirm() {
console.log('confirm called...')
this.confirmationService.confirm({
  message: 'Are you sure that you want to proceed?',
  header: 'Confirmation',
  icon: 'pi pi-exclamation-triangle',
  accept: () => {
    this.msgs = [{ severity: 'info', summary: 'Confirmed', detail: 'You have accepted' }];
    console.log('accept...')
  },
  reject: () => {
    this.msgs = [{ severity: 'info', summary: 'Rejected', detail: 'You have rejected' }];
  }
});

Full Code here on Stackblitz

https://stackblitz.com/edit/jjay-angular-primeng-gaiizg?file=src%2Fapp%2Fapp.module.ts

Upvotes: 3

Views: 11506

Answers (1)

Dinesh Kumar
Dinesh Kumar

Reputation: 503

Instead of <p>confirm-dialog</p> you have to use something <p-confirmDialog header="Confirmation" width="425"></p-confirmDialog>

Upvotes: 10

Related Questions