I have a problem when I try to select a date in the date picker, any date I select resets to today's date and I don't know why. Can someone please help me with this issue?
This is the stackblitz, what should I change for the date to be the date I want to be displayed? Thanks a lot
https://stackblitz.com/edit/angular-mbj5vz
Regards
As stated in the comments, you are initializing the date after pressing the button.
Edit - try this instead please:
ngOnInit() {
this.form = this.builder.group({
dob: new Date()
});
}
formatFormDate(date: Date) {
return formatDate(date, this.dateFormat, this.language);
}
setDate() {
let newDate = this.form.get('dob').value;
this.form.patchValue({ dob: this.formatFormDate(newDate) });
}