Angular 2 Date Input not binding to date value

后端 未结 10 2164
醉梦人生
醉梦人生 2021-01-30 16:16

trying to get a form set up but for some reason, the Date input in my html is not binding to the object\'s date value, despite using [(ngModel)]

html:

&l         


        
10条回答
  •  无人共我
    2021-01-30 16:28

    As per HTML5, you can use input type="datetime-local" instead of input type="date".

    It will allow the [(ngModel)] directive to read and write value from input control.

    Note: If the date string contains 'Z' then to implement above solution, you need to trim the 'Z' character from date.

    For more details, please go through this link on mozilla docs.

提交回复
热议问题