【发布时间】:2019-09-14 13:39:13
【问题描述】:
我正在尝试修复其他人代码中的错误。我对角度很陌生。 当用户单击链接按钮时,我试图打开一个弹出窗口。当用户单击名为“拒绝”的链接按钮时,他会收到一条确认消息,说您确定要拒绝。如果单击是按钮,则会打开弹出窗口。以下是是和否问题的代码:
<div *ngIf="VerifyBatch.PromptStopEnvelope == true">
<span>
<i class="fa fa-exclamation-triangle fa-2x" aria-hidden="true">
<span class="information">
Are you sure you want to {{VerifyBatch.EnvelopeStopAction}} Envelope {{VerifyBatch.SelectedMail.MailNumber}} ?
</span>
</i>
</span>
<span>
<button class="appHighPriorityBtn" (click)="InitSelectedMail();VerifyBatch.PromptStopEnvelope = false;openDialog(VerifyBatch.SelectedMail, VerifyBatch.EnvelopeStopAction, 'Envelope')">
YES
</button>
<button class="appBtnConfirmation" (click)="InitSelectedMail();VerifyBatch.PromptStopEnvelope = false">
NO
</button>
</span>
</div>
请看下图是否确认:
单击“是”后,我会看到以下窗口:
以上窗口要求用户输入代码。如果我没有输入代码并单击“拒绝信封”按钮,则弹出窗口将关闭,并且父窗口上会出现一条错误消息,提示“请输入代码”。下图是:
下面是错误代码。此代码在弹出窗口中:
<div *ngIf="data.Action == 'Reject'">
<div class="inputMargin" *ngIf="!data.IsFreeText">
<mat-form-field class="fullWidth margintop10">
<mat-select placeholder="Rejection Code" [(ngModel)]="data.RejectCode" name="rejectionCode">
<mat-option *ngFor="let rejectionCode of data.RejectionCodesSelect" [value]="rejectionCode.Code">
{{rejectionCode.Code}}
</mat-option>
</mat-select>
</mat-form-field>
</div>
再次,我可以单击“拒绝链接”按钮,然后再次出现确认消息,询问“您确定要拒绝信封”。如果我说“否”,则不会出现弹出窗口,但“请输入拒绝代码”的旧错误消息不会消失。如果我点击“否”确认消息,如何让消息消失?
我知道如果我取消这两个变量:
this.MailItemValidationErrors = null;
this.MailValidationErrors = null;
在我的组件文件中,消息将消失,但我不确定将哪个函数分配给这两个变量。以下是我的部分组件代码:
Component({
selector: 'detach-dialog',
templateUrl: './detachreason.dialog.component.html',
})
export class DetachDialogComponent {
constructor(
public dialogRef: MatDialogRef<DetachDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: any) { dialogRef.disableClose = true; }
onNoClick(): void {
this.dialogRef.close();
}
}
@Component({
selector: 'app-verifybatch',
templateUrl: './verifybatch.component.html'
})
export class VerifybatchComponent implements OnInit {
openDialog(mailOrItem, action: string, itemType: string):
// some variables are assigned here
dialogRef.afterClosed().subscribe(result => {
// this.RefreshScreen();
this.MailValidationErrors = null;
if (result != null) {
// code here
任何帮助都将受到高度赞赏。
【问题讨论】:
标签: angular