我正在尝试清除日期字段,用户必须手动输入日期。我正在使用角度日期材料。
这是我的错误
这是我的html代码。
<div *ngFor="let item of dialogData?.milestoneData?.maintenanceCountryAssumption; let mcaIndex=index">
<div *ngFor="let element of item.trialDesignElement; let elementIndex=index;">
{{item.trialDesignElement}}
<div class="row">
<div class="col-md-4">
{{ element.trialName}}
</div>
<div class="col-md-4">
<mat-form-field *ngIf="element.firstPatientInDate">
<input [disabled]="!enableEdit"
(dateChange)="setChange(mcaIndex, elementIndex,'firstPatientInDate', $event)" matInput
[matDatepicker]="fpd" placeholder="Choose a date"
[value]="getData(element.firstPatientInDate)" name="{{elementIndex}}--{{mcaIndex}}">
<button mat-button *ngIf="element.firstPatientInDate" matSuffix mat-icon-button
aria-label="Clear" (click)="clearFirstDateField(mcaIndex, elementIndex)">
<mat-icon>close</mat-icon>
</button>
<mat-datepicker-toggle matSuffix [for]="fpd"></mat-datepicker-toggle>
<mat-datepicker #fpd></mat-datepicker>
</mat-form-field>
<mat-form-field *ngIf="!element.firstPatientInDate">
<input (dateChange)="setChange(mcaIndex, elementIndex,'firstPatientInDate', $event)" matInput
[matDatepicker]="dup" placeholder="Choose a date" name="{{elementIndex}}--{{mcaIndex}}"
[(ngModel)]="element.firstPatientInDate">
<button mat-button *ngIf="element.firstPatientInDate" matSuffix mat-icon-button
aria-label="Clear" (click)="clearSecondDateField(mcaIndex, elementIndex)">
<mat-icon>close</mat-icon>
</button>
<mat-datepicker-toggle matSuffix [for]="dup"></mat-datepicker-toggle>
<mat-datepicker #dup></mat-datepicker>
</mat-form-field>
</div>
<div class="col-md-4">
<mat-form-field *ngIf="element.lastPatientInDate">
<input [disabled]="!enableEdit" required [ngClass]="{'lpiError': element.lpiError}" matInput
[matDatepicker]="dup3" [min]="dateFilter(element.firstPatientInDate)"
name="{{elementIndex+1}}--{{mcaIndex}}" placeholder="Choose a date"
[value]="getData(element.lastPatientInDate)">
<button mat-button *ngIf="element.lastPatientInDate" matSuffix mat-icon-button
aria-label="Clear" (click)="clearLPIFirstDateField(mcaIndex, elementIndex);">
<mat-icon>close</mat-icon>
</button>
<mat-datepicker-toggle matSuffix [for]="dup3"></mat-datepicker-toggle>
<mat-datepicker #dup3></mat-datepicker>
</mat-form-field>
<mat-form-field *ngIf="!element.lastPatientInDate">
<input required [ngClass]="{'lpiError': element.lpiError}"
(dateChange)="setChange(macIndex, elementIndex,'lastPatientInDate', $event)" matInput
[matDatepicker]="dup4" [min]="dateFilter(element.firstPatientInDate)"
name="{{elementIndex+1}}--{{mcaIndex}}" placeholder="Choose a date"
[(ngModel)]="element.lastPatientInDate">
<button mat-button *ngIf="element.lastPatientInDate" matSuffix mat-icon-button
aria-label="Clear" (click)="clearLPISecondDateField(mcaIndex, elementIndex);">
<mat-icon>close</mat-icon>
</button>
<mat-datepicker-toggle matSuffix [for]="dup4"></mat-datepicker-toggle>
<mat-datepicker #dup4></mat-datepicker>
</mat-form-field>
</div>
</div>
</div>
这是我的 ts 代码。
clearFirstDateField(mcaIndex, elementIndex) {
this.dialogData.milestoneData.maintenanceCountryAssumption[mcaIndex].trialDesignElement[elementIndex].
firstPatientInDate = '';
}
实际上我得到了错误*ngIf="element.firstPatientInDate"
在控制台中我可以看到 FPID
请让我知道我在这里做错了什么。