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

DatepickerPopup error when changing input field #3713

Closed
csvn opened this issue May 26, 2015 · 9 comments
Closed

DatepickerPopup error when changing input field #3713

csvn opened this issue May 26, 2015 · 9 comments

Comments

@csvn
Copy link

csvn commented May 26, 2015

When changing an input field with the datepicker-popup directive (in 0.13.0), an error is thrown when the starting value is a time string ('yyyy-MM-dd').

TypeError: baseDate.getFullYear is not a function
http://plnkr.co/edit/oKNbNp07cJompsK6NBVr?p=preview

This does not occur in 0.12.1:
http://plnkr.co/edit/GFHEvBbmsgfHKK7NrYeN?p=preview

Is this a bug or am I missing something?

@gmarziou
Copy link

I experience same problem when I manually enter a date in the input text not using the popup.

@wesleycho
Copy link
Contributor

I have a proposed fix, if you take a look at the referenced PR above

@gmarziou
Copy link

Great, thanks

@bob-lee
Copy link

bob-lee commented Feb 12, 2016

After upgrading from 0.14.3 to 1.1.2, I am getting "TypeError: this.activeDate.getFullYear is not a function". It seems like previous version handles both UTC string and Date object ok but 1.1.2 seems to have issue with UTC string?

@thowar2
Copy link

thowar2 commented Feb 12, 2016

Same, I had to pass it a new Date object, the date string was throwing an error.

@bob-lee
Copy link

bob-lee commented Feb 12, 2016

It turns out that ngmodel should be JavaScript date object. Fair enough. I was maintaining dates as utc strings for sorting.

@icfantv
Copy link
Contributor

icfantv commented Feb 12, 2016

Yes. The API was changed to require the model to be a Javascript Date object due to issues that arose with how different browsers handle date strings - even ISO 8601 formatted ones. The issues forum is literally littered with issues that discuss the reason for this so if you're looking for something more in-depth, please feel free to search that.

Also, @bob-lee, it's never a bad idea to go over the CHANGELOG for each version to look for breaking changes. This was one such change, however it was made in 0.13.x and a regression was introduced that allowed strings to be used again - which was rectified in the 1.1.0 release (I believe).

@ilaipi
Copy link

ilaipi commented Sep 20, 2016

So, After the change, what's the right way to use this?
I have an element bind to foo.date, and I response

[
    {
        name: 'bar', 
        date:"2016-08-28T16:00:00.000Z"
    },
    //......
]

So, I need to for-each my response and transform date?

@bob-lee
Copy link

bob-lee commented Sep 20, 2016

Between server and client, date is normally transfered as string whereas datepicker requires to feed date object, so string to date (on response / page load) and date to string (on post) transforms needed.

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

9 participants