Subset of Dialog to make it easier to create a confirm dialog with backed by a confirm service for reuse so could be fired from any action.
import {ConfirmDialogModule,ConfirmationService} from 'primeng/primeng';
<p-confirmDialog header="Confirmation" icon="fa fa-question-circle" width="425"></p-confirmDialog>
<button type="text" (click)="confirm()" pButton icon="fa-check" label="Confirm"></button>
export class ConfirmDialogDemo {
constructor(private confirmationService: ConfirmationService) {}
confirm() {
this.confirmationService.confirm({
message: 'Are you sure that you want to perform this action?',
accept: () => {
//Actual logic to perform a confirmation
}
});
}
}
I want some more functionality in dialog like button label text because I have more confirmation dialog in a a single template.
I want to pass the button labels text, like message header and icon from confirm() function.
I red primeng tutorial. tutorial suggest that by using acceptLabel attribute, Its possible to change button lable text but in my confirm function its giving error that confirm function doesn't have acceptLabel attribute.
Is this confirmDialog module support that functionality? If yes, what could be the right format of the code structure.
Any suggestion could be appreciated.
thanks.
What I think could fit nicely is allow html messages.
Instead of
<span class=\"ui-confirmdialog-message\">{{message}}</span>
We do
<span class=\"ui-confirmdialog-message\" [innerHTML]="message"></span>
What do you think, @cagataycivici ?
@KumarGovindh Did you find how to customize acceptLabel and rejectLabel?
Hi again,
I found how to do it, you just have to defined in you p-confirmDialog acceptLabel=""; for example:
<p-confirmDialog id="popupBorrar" header="Confirmation" width="425" acceptLabel="Add" #cd>
Why cant we simply pass the confirmdialog template to the service?
Why cant we define multiple confirmdialogs per page identified by #id or something like that so we can target it with the .confirm() function?
What the hell?
@barocsi Take a look at p-dialog.
Thanks, but this is not the way it should work. Why would I pollute my static dom with dialogs instead of having generic templates that I can display dynamically? It smells like an anti-pattern.
Has anyone found the proper solution ?
Any news about this feature? Should we open an issue for creating more confirmDialog on the same page?
Does the p-confirmDialog support a ng-template pTemplate="body" ?
the solution for my is appendTo="body"
Did you have any possible in multi line of content in confirmation box ?
Is there no way to close these confirmation dialogs using the service? I want to display a "Your session is going to expire" message, and close the confirmation if the session expires鈥攂ut there doesn't appear to be a way to do that.
@shaungrady use normal dialog with modal=true
Most helpful comment
Thanks, but this is not the way it should work. Why would I pollute my static dom with dialogs instead of having generic templates that I can display dynamically? It smells like an anti-pattern.