angular - PrimeNG ConfirmDialog 中的 acceptLabel、acceptVisible 不起作用
问题描述
我试图从我的 Angular 应用程序的 component.ts 中自定义 PrimeNG ConfirmDialogacceptLable
,但是,acceptVisible
属性不起作用。, 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 之前acceptLabel
无法rejectLabel
设置属性:请参阅https://github.com/primefaces/primeng/issues/5090ConfirmationService
如果您必须坚持使用版本 4.1.1,则必须在 HTML 模板中指定它
推荐阅读
- ruby-on-rails - rails f.number_field vs number_field_tag
- wordpress - Wordpress - Woocommerce:重新缩放透明 png 后的背景噪音
- c# - LINQ - 如何比较组中的前两项然后下一项?
- sorting - elasticsearch有没有办法对数组字段的记录进行排序?
- solidity - Solidity 语法的设计目标是什么
- android - 实时数据返回旧值,onChanged 多次触发
- amazon-web-services - 在计费恐慌中锁定公共站点访问
- c# - 在 UWP 应用中更改 Flyout 的高度和宽度
- android - 单击登录按钮后,React 本机发布签名的 apk 文件崩溃
- azure-devops - 如何通过 BuildId 获取 PullRequestId?