I am using material date picker for my date picker. I am trying to enter the date manually
With my current scenario where I was able to enter number 1 The date is taking as 01-JAN-2021
If I Enter the number 2 The date is considering as 01-FEB-2021 when I analyzed the code In value property I am using getData
method so when I am changing the date the rest of the value it is taking from getData
method
Here is my HTML code
<mat-form-field>
<input [disabled]="!enableEdit" (dateChange)="setChange(item2.dataName,'fpInDate')"
matInput [matDatepicker]="i" placeholder="Choose a date"
[value]="getData(item2.fpInDate)" name="{{i}}--{{n}}"
[(ngModel)]="item2.fpInDate">
<button mat-button *ngIf="item2.fpInDate" matSuffix mat-icon-button aria-label="Clear"
(click)="item2.fpInDate=''">
<mat-icon>close</mat-icon>
</button>
<mat-datepicker-toggle matSuffix [for]="i"></mat-datepicker-toggle>
<mat-datepicker #i></mat-datepicker>
</mat-form-field>
Get Data Method:
getData(dates: any) {
return new Date(dates);
}
SetChange method:
setChange(dataName, dateType) {
this.dataChanged = true;
this.designData.push({
DataName: dataName,
dateType: dateType,
countryCode: this.dialogData.pageValue.countryCode
});
}
I am totally stuck here please guide me what I am doing wrong here.
If I remove ngmodel from the code I was able to see the date and edit the date but the problem is it is not updating in the Table.
team I am stucked here not able to get the answer please guide me