I have a date-filter
component that I am using in my Ember application that only works on initial render, not on a page reload, or even if I save a file (which triggers the application to live update).
In the main template of my application, I render the date-filter like this passing it a unix timestamp
{{date-filter unixepoch=item.date}}
Then, in components/date-filter.js
, I use a computed property called timeConverter
to change the unix epoch into a time string formatted according to user's language of choice, and then in my templates/components/date-filter.hbs
file I do {{timeConverter}}
to display the results
timeConverter: function(){
//step 1: get the epoch I passed in to the component
var epoch = this.get('unixepoch');
//step 2: create a human readable date string such as `Jun 29, 2015, 12:36PM`
var datestring = new Date(epoch)
//do language formatting --code omitted as the problem is with step2
}
It is step 2
that fails (returning invalid date
) if I refresh the page or even save the file. It always returns the proper date string the first time this component is called. Even if I do new Date(epoch)
in the parent component, and try to pass the result in to this component (to do foreign language formatting), I'm having the same problem.
Question: how can I figure out what's happening inside new Date(epoch), or whether it's an issue related to the component?
Aucun commentaire:
Enregistrer un commentaire