Angular 7-启动-确认对话框不起作用
HTML
<p>confirm-dialog</p>
<button type="button" (click)="confirm()" pButton icon="pi pi-check" label="Confirm"></button>
打字稿
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' }];
}
});
此处位于Stackblitz上的完整代码
https://stackblitz.com/edit/jjay-angular-primeng-gaiizg?file=src%2Fapp%2Fapp.module.ts
答案 0 :(得分:1)
您必须使用<p>confirm-dialog</p>
来代替<p-confirmDialog header="Confirmation" width="425"></p-confirmDialog>