Best Practices: accessing app config from addon code

Depending on what you have in your addon folder, you can access the app’s config.

For example if you have a Mixin that is used by some object in the consuming that is looked up via the container/resolver (like route, controller, component, view, etc) then you can lookup the app’s config like the following:

modulePrefix: Ember.computed(function() {
  var applicationConfig = this.container.lookup('config:environment');

  return applicationConfig.modulePrefix;
})
4 Likes