gpt4 book ai didi

angular - PrimeNG ConfirmDialog 中的 acceptLabel、acceptVisible 不起作用

转载 作者:太空狗 更新时间:2023-10-29 18:29:17 26 4
gpt4 key购买 nike

我正在尝试自定义 PrimeNG ConfirmDialog在我的 Angular 应用程序的 component.ts 中,但是 acceptLableacceptVisible 属性不起作用。 icon, header, message, accept(), reject() 等一切正常。有什么线索吗?

PrimeNG 版本:4.1.1

下面是代码:

组件.html:

<p-confirmDialog closable="false" #cd>
<p-footer>
<button type="button" (click)="cd.accept()"></button>
<button type="button" (click)="cd.reject()"></button>
<p-footer>
</p-confirmDialog>

组件.ts:

import {ConfirmationService} from 'primeng/primeng';

@Component({
..
providers: [ConfirmationService]
})

constructor(private confirmService: ConfirmationService){
this.notAllowedToLeave = true; /* Based upon this variable the confirmation dialog will display the Accept button i.e. "Yes, Sure!" */
...
}

this.confirmService.confirm({
message: 'Are you sure you want to exit?',
header: 'Warning: Quit Application',
icon: 'fa fa-exclamation-triangle',
accept: () => { /* My accept actions */ },
reject: () => { /* My reject actions */ },
acceptVisible: this.notAllowedToLeave ? false : true, /* No effect */
acceptLabel: 'Yes, Sure!', /* Giving Error: 'acceptLabel' does not exist in type 'Confirmation' */
rejectLabel: 'No, I Don't!' /* Giving Error: 'rejectLabel' does not exist in type 'Confirmation' */
});

最佳答案

在 PrimeNG 5.2.5 之前,属性 acceptLabelrejectLabel 不能用 ConfirmationService 设置:见 https://github.com/primefaces/primeng/issues/5090

如果必须坚持使用 4.1.1 版本,则必须在 HTML 模板中指定它

https://stackblitz.com/edit/primeng411-confirmation-test

关于angular - PrimeNG ConfirmDialog 中的 acceptLabel、acceptVisible 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50481647/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com