I am building the ionic app(v-4),I am unable to display the date
from the api
. My JSON
looks like this:
{
user_name: "Jhon"
status: "Open"
meeting_date: "31-08-2019"
remark: "No remarks"
request_id: 958
}
I have tried to display the date
in <ion-datetime>
as shown below:
HTML
<form [formGroup]="editForm">
<ion-item>
<ion-label position="stacked">Date</ion-label>
<ion-datetime formControlName="meeting_date" [(ngModel)]="resObj.meetingDate"></ion-datetime>
</ion-item>
</form>
TS
public resObj;
ngOnInit() {
this.resObj = this.navParams.data.paramRequest;
this.updateForm = this.fb.group({
remark : [null],
.
.
meeting_date: [null],
});
}
I got this error: Error parsing date: "undefined". Please provide a valid ISO 8601 datetime format: https://www.w3.org/TR/NOTE-datetime
So i tried this solution ===> ionic 2 ion-datetime ISO Format issue
i,e Using ISO format before displaying the date
in the template like this:
HTML
<form [formGroup]="editForm">
<ion-item>
<ion-label position="stacked">Date</ion-label>
<ion-datetime formControlName="meeting_date" [(ngModel)]="meetingDate "></ion-datetime>
</ion-item>
</form>
TS
public resObj;
ngOnInit() {
this.resObj = this.navParams.data.paramRequest;
const meetingDate = this.resObj.meeting_date.toISOString(); <======
this.updateForm = this.fb.group({
remark : [null],
.
.
meeting_date: [null],
});
}
Still i was unable to show date
in ion-datetime
I am unable find what went wrong.