samedi 23 janvier 2016

Inject a service into an Ember Object [not an Ember Controller]

I'm trying to inject an Ember service into an Ember Object but keep getting the following error:

"Assertion Failed: Attempting to lookup an injected property on an
object without a container, ensure that the object was instantiated 
via a container."

My code looks essentially something like the following:

const Model = Ember.Object.extend({
  store: Ember.inject.service(),

  destroyRecord() {...},

  serialize() {...},

  deserialize() {...},
});

let newModel = Model.create();
newModel.get('store');

Note: it does work if I inject the service into a Controller, but not an object. Haven't had any luck trying to figure out how to register the Object with the Ember container.




Aucun commentaire:

Enregistrer un commentaire