【发布时间】:2018-11-02 01:06:48
【问题描述】:
我试图在我的 Angular 应用程序的 component.ts 中自定义 PrimeNG ConfirmDialog,但 acceptLable、acceptVisible 属性不起作用。 icon、header、message、accept()、reject() 等都工作正常。这有什么线索吗?
PrimeNG 版本:4.1.1
以下是代码:
component.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>
component.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' */
});
【问题讨论】:
-
我认为您通过在模板文件中写入
标记来覆盖它,只需从模板中删除 标记并尝试运行。 -
是的,你是对的。它被覆盖了。但正如@splash 下面所说,PrimeNG 版本是另一个原因。