Here is my code. I have a date picker where it shows a certain date for a property in my app. I want the date picker to show that date only if, IsPrimerExists is true. If it's not true, I want it to be null. Right now, the date picker is null for both conditions. What should I fix to achieve what I want?
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>
TS:
productionOrder: IProductionOrder = {};
constructor() {
if (_dialogRef.id != "ProductionOrder") {
this.productForms = _data;
if (this.productForms && this.productForms.length > 0) {
this.totalProducedAmount = this.productForms[0].TargetQuantity;
}
let i = 0;
this.productForms.forEach((x) => {
if (i == 0) {
this.countryCheck1 = x.IsPeriod;
this.CountryVisible1 = true;
this.Country1 = x.GeoType.Name;
this.Market1 = x.MarketType.Name;
this.previousCheck1 = x.IsPreviousMonth;
this.productionValue1 =
_dialogRef.id == "ProductForm" ? true : false;
if(this.productionOrder.IsPrimerExists){
this.countryDate1 = x.ProductionDate;
}
else{
this.countryDate1 = null;
}
}
i++
}
IProductionOrder:
IsPrimerExists?: boolean;

this.countryDate1=null. NOTE: Remember that to asign a value you need give a Javastring Date object. NOTE2 the type of your variable should be "any":countryDate:any