I tried to do a helper {{current-date}} which should show the current date on the template index.hbs moment.js installed with npm. However, ember v2.4.2 has displayed error in the helper current-date.js, moment() undefined. moment will be soon deprecated, thus something else is required. I have tried something like this for app/helpers/current-date.js:
export function currentDate(params) {
return moment().format();
}
export default Ember.Helper.helper(currentDate);
Is it correct without any params given? Should it have params[0] value 0 or "" ?
I have installed on my OS X10.10 Homebrew 0.9.5, Node.js v5.9.0, ember v2.4.2, npm v3.7.3, bower v1.7.7
This would be easy to do with plain JavaScript:
var d = new Date();
console.log(d.toDateString());
I couldn't make it work either in the helper. What is the right way to do this?
Aucun commentaire:
Enregistrer un commentaire