Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Correct way to access current application configuration

I added some configurations to myapp/config/environment:

if (environment === 'development') {
  ENV.APP.AuthURL = 'http://localhost:5000/';
}

Now, to access this configuration should I use some method or directly accessing window.Myapp?

like image 916
Mateus Vahl Avatar asked Mar 28 '15 23:03

Mateus Vahl


1 Answers

You can access it by importing environment.js using the line below:

import config from '../config/environment';

For example, lets say you want to access your configuration in a controller. This is what it would look like:

import Ember from 'ember';
import config from '../config/environment';

export default Ember.Controller.extend({
  foo: config.APP.AuthURL
});

If you need to, you can now access it in your controller's template using:

{{foo}}
like image 186
rog Avatar answered Sep 20 '22 07:09

rog