Issue
I have a strange problem, in my html I defined-
<mat-radio-button value="embargoed">
<div>Everyone, limited by date</div>
<mat-form-field *ngIf="data.selected === 'embargoed'">
<mat-label>Available from date</mat-label>
<input matInput [matDatepicker]="picker" #input [(ngModel)]="date">
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker #picker></mat-datepicker>
</mat-form-field>
</mat-radio-button>
in my comonent I initialized-
date = new Date();
I have an OnSubmit function that does-
onSubmit(){
if (this.data.selected === 'embargoed') {
this.data.date = this.date;
}
}
In debud I can see that this.date is a Moment object instead of a Date object, any idea why?
Solution
I found the reason. In my app.module.ts
I had declared:
{provide: MAT_DATE_FORMATS, useValue: MAT_MOMENT_DATE_FORMATS}
Answered By - danda
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.