Reputation: 245
I am very new to Angular and Angular Material.
For the dates my backend wants it to be in zonedDate Format. (e.g.: 2018-04-11T02:12:04.455Z[UTC])
So I am getting value in the above format, which is not binding to mat-datepicker.
Here is html code:
<mat-form-field class="fx-cell-1" floatLabel="never">
<input matInput name="myDate" [matDatepicker]="myDate" placeholder="Date of Expense"
[(ngModel)]="myDate" #myDate="ngModel" [max]="maxDate" required >
<mat-datepicker-toggle matSuffix [for]="myDate"></mat-datepicker-toggle>
<mat-datepicker #myDate></mat-datepicker>
</mat-form-field>
So here ngModel is not binding value to datepicker.
After some more observation, I realized that:
The date with value "2018-04-11T02:12:04.455Z[UTC]" is binding to the datepicker.
The date with value "2018-04-02T14:00Z[UTC]" is not binding to the datepicker.
Any suggestion???
Upvotes: 0
Views: 3664
Reputation: 245
So, basically, you can convert this date with javascript function toISOString().
or just by creating new Date() object.
In my case date was converting into some wrong format and so was getting an error.
Upvotes: 1