首页 > 解决方案 > 角日期选择器空值

问题描述

这是我的代码。我有一个显示日期选择器的对话框。日期选择器总是以日期打开,但是如果IsPrimerExists值为 false,我希望日期选择器为空。我怎样才能做到这一点?

HTML:

<mat-form-field appearance="outline" *ngIf="!productionValue1">
    <mat-label>{{'İmalat Tarihi(' + Country1 +' '+Market1+')'}}</mat-label>
    <input matInput [matDatepickerFilter]="filterWeekend" [matDatepicker]="picker" [(ngModel)]="countryDate1"
        name="countryDate1">
    <mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
    <mat-datepicker #picker></mat-datepicker>
</mat-form-field>

IProductionOrder 接口:

IsPrimerExists?: boolean;

在此处输入图像描述

标签: javascripthtmlangulartypescript

解决方案


选择器是绑定的 [(ngModel)]="countryDate1",所以如果你将 countryDate1 设置为 null 那么我猜它会在没有日期的情况下打开


推荐阅读