In Angular 13 application, using
the edit code
loadEventToEdit() {
this.eventService.getEventByCode(this.eventCode).subscribe((res) => {
this.event = res;
console.log('the event to update', this.event);
this.theForm.patchValue(res);
Rest of fileds path value is working fine.
CodePudding user response:
Before patchValue
set the date as new Date.
loadEventToEdit() {
this.eventService.getEventByCode(this.eventCode).subscribe((res) => {
this.event = res;
console.log('the event to update', this.event);
this.event.timing.eventStartDate = new Date(
this.event.timing.eventStartDate
);
this.theForm.patchValue(this.event);
CodePudding user response:
Give complete way to your res where res have to patched. For FormArray you have to make getter first and the can you use Push or insert method to patch with form array
loadEventToEdit() {
this.eventService.getEventByCode(this.eventCode).subscribe((res) => {
this.event = res;
this.theForm.controls['eventStartDate'].patchValue(this.event.timing.eventStartDate);
})
}