Skip to content
This repository was archived by the owner on May 28, 2019. It is now read-only.

ui-date-format error in angular 1.3.0-rc.4 #96

Closed
motiejuss opened this issue Oct 6, 2014 · 14 comments
Closed

ui-date-format error in angular 1.3.0-rc.4 #96

motiejuss opened this issue Oct 6, 2014 · 14 comments

Comments

@motiejuss
Copy link

"Error: ng-Model value must be a Date object - currently it is a string - use ui-date-format to convert it from a string"

Markup:

<input type="text" ui-date="datePickerOptions" ui-date-format="dd-mm-yy" class="datepicker" name="uBirthday" ng-model="User.Birthday" readonly required />

Wasn't an issue in 1.3.0-rc.3

@CWSpear
Copy link

CWSpear commented Oct 13, 2014

Still an issue in 1.3.0-rc.5

@vvakame
Copy link
Contributor

vvakame commented Oct 14, 2014

Still an issue in 1.3.0.
input directive convert Date to string after ui-date link prosess. https://github.com/angular/angular.js/blob/10644432ca9d5da69ce790a8d9e691640f333711/src/ng/directive/input.js#L905

@giannisp
Copy link

A quick fix that works for me at the moment is to replace "modelCtrl.$formatters.push" with "modelCtrl.$formatters.unshift".

@justinwinslow
Copy link

Related: angular/angular.js#9218

Not sure why this matters, though, uiDateFormat is expecting a string anyway.

Edit - Oh, I guess it's because angular runs the formatters backwards (as mentioned in that issue thread)? That's why using unshift works.

@vvakame
Copy link
Contributor

vvakame commented Oct 14, 2014

@giannisp cool! 👍

@alexanderchan
Copy link
Contributor

I believe this is fixed by what I have done in this pull request #94 does it work for you?

alexanderchan@ee6fa88

@justinwinslow
Copy link

Here's another option, just remove the default formatter: https://github.com/justinwinslow/ui-date/blob/master/src/date.js#L90

@phillipCouto
Copy link

I am also experiencing this issue and PR #94 resolves the issue for me. I am using angularjs 1.3.0

@treasonx
Copy link

This is a blocking issue for me when upgrading my application to 1.3.0 😭

@nathasm
Copy link

nathasm commented Oct 19, 2014

I don't believe PR #94 works. I'm using moment to generate a Date object like: moment().startOf('day').toDate() and while it doesn't complain it's not displaying the date. The input box shows mm/dd/yyyy.

How I construct the date with moment has worked with ui-date from 1.0.X through 1.3.0-rc's. Other suggestions?

@Lewik
Copy link

Lewik commented Oct 20, 2014

I broke my head, trying to fix it.
@giannisp Thanks for hotfix =)
PR #94 doesn't work for me.

@CWSpear
Copy link

CWSpear commented Oct 27, 2014

@giannisp's fix worked for me, too. Has anyone thought to make a PR with this change?

@alexanderchan
Copy link
Contributor

Hi @CWSpear I've incorporated that along with another set of fixes in #99 and at least it passes the tests and works for the cases that I have.

@nathasm, I haven't added a test case for moment integration but perhaps #99 with fixes from giannisp will also help. If it doesn't work, perhaps a small jsbin with your case could help us find out what is wrong.

@nathasm
Copy link

nathasm commented Oct 28, 2014

After spending some time investigating, it appears that my issue was with the version of jquery-ui I was using: 1.8.16. Not sure why the angular upgrade would expose this, but I've upgrading jquery-ui and my issue has been resolved.

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

No branches or pull requests

10 participants