samedi 4 février 2017

How to use momentjs on a Ember.js Router

I'm trying to use:

import moment from 'moment';

but throw this error:

Could not find module 'moment' imported from 'myproject/routes/myroute'

If a simple use moment() as:

model(params){
  return this.get('store').query('myentity', {
    filter: {
      timestamp: {
        $ge: moment(params.day).startOf('day').format('x'),
        $le: moment(params.day).endOf('day').format('x')
      }
    }
  });
}

throw this error:

Error while processing route: myroute Cannot read property '_calendar' of undefined TypeError: Cannot read property '_calendar' of undefined

Note 01: I import momentjs from bower, update my jshintrc to include "moment" on predec and include "moment" on ember-cli-build too.

Note 02: I see ember-moment addon, but I want to learn how it work to apply to possible other libraries.




Aucun commentaire:

Enregistrer un commentaire