lundi 15 février 2016

How to use store in an initializer

I want to use the store in an initializer to I tried to do this :

export function initialize(application) {
  application.inject('controller', 'store', 'service:store');
  this.store.createRecord('model');
}

export default {
  name: 'modify-models',
  initialize
};

With this, this.store is undefined.

As in the doc, I tried var store = application.lookup('service:store'); but application.lookup is undefined.

I also tried var store = Ember.inject.service('store'); but store is undefined.

I can't find the right way. What's the solution?




Aucun commentaire:

Enregistrer un commentaire