I'm using .net core api with angular7.

I have a problem to convert dateTime to Date with ngModel

 <input class="form-control" name="dateT"
 [(ngModel)]="exp.dateTo  |date:'yyyy-MM-dd'" #dateT="ngModel" type="date"/>

1 Answers

0
Ashok On Best Solutions

Instead if two-way binding.Use one way and have a event handler to update User input.

<input class="form-control" name="dateT" (ngModelChange)="updatedate($event)" [ngModel]="exp.dateTo |date:'yyyy-MM-dd'" #dateT="ngModel" type="date"/>

In your ts file add updatedate to update the ngmodel

 updatedate(event) {

        this.exp.dateTo = new Date(event);
    }