I have this function to select the date which works fine
formatDateField(event: Date, formControl: string) {
this.form
.get(formControl)
.patchValue(
this.datePipe.transform(event.getTime(), "yyyy-MM-dd'T'HH:mm:ss")
);
}
I added a button to add the days to it using this code below but says undefined in developers tool > console:
addDaysToDateForm(formName: string, days: number) {
let formDate: Date = this.form.get(formName).value || new Date();
formDate.setDate(formDate.getDate() + days);
this.form.get(formName).setValue(formDate);
}
setTodayForm(formName: string) {
this.form.get(formName).setValue(new Date());
}
Any idea what's wrong with it?