Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

ng-init and ng-model don't properly initialize value of input type date #8239

Closed
ilanbiala opened this issue Jul 17, 2014 · 6 comments
Closed

Comments

@ilanbiala
Copy link

<input type="date" ng-model="startDate">

With this snippet, even if $scope.startDate = 1/1/2013, which is a valid date, it is not shown as a value in the input. Just mm/dd/yyyy like the ng-model isn't even there. Ng-init doesn't do anything in this case either.

@Narretz
Copy link
Contributor

Narretz commented Jul 17, 2014

Since 1.3.0-beta.1, input type date can only be bound to a Date object, see docs: https://code.angularjs.org/1.3.0-beta.15/docs/api/ng/input/input%5Bdate%5D

You cannot use ng-init for this use case (you should always intialize on the controller anyway)

@ilanbiala
Copy link
Author

Is there any reason that a Date object is required? Is it going to work with strings as well, or is that not intended?

@Narretz
Copy link
Contributor

Narretz commented Jul 17, 2014

A date object is currenty required, because the input[date] directive will convert the input to a date object anyway. There's an issue open to allow strings as a starting value, but it hasn't gained much traction yet: #7066

@pkozlowski-opensource
Copy link
Member

OK, let's centralise the discussion in #7066 then.

@MuhammadTayyeb
Copy link

hi
can any one help angulajs DatePicker

@gkalpak
Copy link
Member

gkalpak commented Aug 17, 2016

@MuhammadTayyeb, for general support questions, please, use one of the appropriate support channels.
GitHub issues are reserved for bug reports and feature requests.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants