我在我的项目中使用primeng。我有一个 mat-tab,两者内部都有相同的组件,该组件是一个带有按钮的表单,当我按下该按钮时会显示一个确认对话框。问题是,当我按下按钮显示确认对话框时,两个选项卡中都会出现。我该如何解决这个问题?
confirmPrinting(event: Event) {
this.confirmationService.confirm({
target: event.target as EventTarget,
message: 'Are you sure with' + this.printSelected +'?',
header: 'Confirmación',
icon: 'pi pi-exclamation-triangle',
acceptIcon:"none",
rejectIcon:"none",
rejectButtonStyleClass:"p-button-text",
accept: () => {
this.messageService.add({ key: 'tc',severity: 'info', summary: 'Confirm', detail: 'Starting print...' });
},
reject: () => {
this.messageService.add({ severity: 'error', summary: 'Cancel', detail: 'Print canceled', life: 3000 });
}
});
}
这是 html:
<button type="submit" class="btn mat-btn" [disabled]="printDisabled" (click)="confirmPrinting($event)"><mat-icon class="tab-icon">print</mat-icon></button>
我希望确认对话框只出现一次,我需要它们是独立的。
不确定你在做这样的事情。
从按钮调用 onSave on (ngSubmit) 函数。
<form #form1="ngForm" *ngIf="organizationHierarchyItem" (ngSubmit)="onSave()">
<button type="submit" (click)="onSave()" class="btn btn-primary btn-sm margin-btn">Save</button>
</form>