I have some p-confirmDialogs that I set based on a variable (check) which is based on corresponding buttons. Currently, I have to click each button twice in order to properly set the variable correctly. Here's the relevant code:
p-confirmDialogs with buttons
<p-confirmDialog width="445" *ngIf="check=='Add'" acceptLabel="Add"></p-confirmDialog>
<p-confirmDialog width="445" *ngIf="check=='Update'" acceptLabel="Update"></p-confirmDialog>
<p-confirmDialog width="445" *ngIf="check=='Delete'" acceptLabel="Delete"></p-confirmDialog>
<div class="ui-grid-col-1">
<button type="button" (click)="confirmAdd()" pButton label="Add"></button>
</div>
<div class="ui-grid-col-1">
<button type="button" (click)="confirmUpdate()" pButton label="Update"></button>
</div>
<div class="ui-grid-col-1">
<button type="button" (click)="confirmDelete()" pButton label="Delete"></button>
the variable and the typescript methods that set the variable
check:string = null;
confirmAdd() {
this.check = "Add";
this.confirmationService.confirm({
message: 'Are you sure that you want to add this data point',
header: "Add Confirmation",
accept: () => {
//this.msgs = [];
//this.msgs.push({severity:'info', summary:'Confirmed', detail:'You have accepted'});
}
});
}
confirmUpdate() {
this.check = "Update";
this.confirmationService.confirm({
message: 'Are you sure you want to update this record?',
header: 'Update Confirmation',
icon: 'fa fa-check',
accept: () => {
//this.msgs = [];
//this.msgs.push({severity:'info', summary:'Confirmed', detail:'Record deleted'});
}
});
}
confirmDelete() {
this.check = "Delete";
this.confirmationService.confirm({
message: 'Are you sure you want to delete this record?',
header: 'Delete Confirmation',
icon: 'fa fa-trash',
accept: () => {
//this.msgs = [];
//this.msgs.push({severity:'info', summary:'Confirmed', detail:'Record deleted'});
}
});
}
Thanks for the help in advance!
PrimeNG p-confirmDialog
-
- Information
-
Who is online
Users browsing this forum: No registered users and 2 guests