mardi 18 juillet 2017

injecting and ember service from outside

Can I inject service to a component from an initializer? I would like to have a property in any component in my app's components that brings static config info. I know I can do this inside the component:

cfgStore: Ember.inject.service('cfgstore-reader')

And I can add an object to my components in an intializar:

let cfg = Ember.Object.extend(cfgStore);

export function initialize(application) {
  application.register('cfgstore:main', cfg);
  application.inject("component", "cfgstore", "cfgstore:main");
}

Can I do the same for an injector? I could find any sample and it does seem to work...




Aucun commentaire:

Enregistrer un commentaire