Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dateTime-local does not bind properly

I am trying to bind an attribute of my model to a dateTime-local input and something is not working properly.

This is my model

$scope.testDate = new Date($.now());

This is my html

<input type="datetime-local" id="exampleInput" name="input" ng-model="testDate" />
value = {{testDate}}

When i start the app the dateTime input shows "mm/dd/yyyy, --:--:--" in the input box, but the "value =" part is displayed with the correct dateTime value.

If i enter a valid date in the input box it will update the value so the binding is working but something with displaying the initial value is not...

What am i missing here?

like image 999
user860067 Avatar asked Aug 11 '14 07:08

user860067


People also ask

Why datetime-local is not working in Firefox?

Input type "datetime-local" is not supported in Firefox hence it shows a text box, in this case, you can use input type as "date". As "datetime-local" shows the time as well and if you have the same requirement, you can use Input type "time" also to show the time. I hope this helps.

Does Firefox support datetime-local?

Browser Support Note: The <input type="datetime-local"> element does not show any datetime field/calendar in Firefox.

What is datetime-local?

Definition and Usage. The <input type="datetime-local"> defines a date picker. The resulting value includes the year, month, day, and time.


1 Answers

AngularJS support the input type datetime-local since version 1.3.0-beta.1

And it is a breaking change that the value in model must be an Date object instead of string like in the previous version.

Therefore, if you would like to use the datetime-local input and bind it with Date object, please ensure to use angularjs version 1.3.0-beta.1 or newer.

like image 194
runTarm Avatar answered Nov 15 '22 04:11

runTarm