Angular 2 Date Input not binding to date value

后端 未结 10 1954
醉梦人生
醉梦人生 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

    Angular 2 completely ignores type=date. If you change type to text you'll see that your input has two-way binding.


    Here is pretty bad advise with better one to follow:

    My project originally used jQuery. So, I'm using jQuery datepicker for now, hoping that angular team will fix the original issue. Also it's a better replacement because it has cross-browser support. FYI, input=date doesn't work in Firefox.

    Good advise: There are few pretty good Angular2 datepickers:

    • https://github.com/emirdeliz/meus-projetos/tree/master/angular2-schedule/app/frontend/components/datepicker

    • https://github.com/MrPardeep/Angular2-DatePicker

    • https://www.npmjs.com/package/ng2-datepicker

提交回复
热议问题