I'm trying to put a date from my database to my input type="date"
field. Strings works perfectly, they all go to form when except date.
My input type is date on the form.
my form :
<input [value]="candidat.birthDate" type="date">
candidat:
export class Candidat {
birthDate!:Date;
}
CodePudding user response:
This is more of a general HTML input error
When you use type="date"
in you input element, you have to comply to its expected values.
The specification illustrates that:
value includes the year, month, and day, but not the time. The time and datetime-local input types support time and date time input
So to make it work you need to adjust datTime string 2022-03-30T00:00:00.000 00:00
you are using. Using the first 10 chars should do the trick:
<input [value]="candidat.birthDate?.substr(0,10)" type="date">
CodePudding user response:
why don't use pipe, just like below:
<input value={{candidat.birthDate | date}} type="date">