Correct way to access current application configuration

前端 未结 3 725
一整个雨季
一整个雨季 2021-02-05 10:39

I added some configurations to myapp/config/environment:

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


        
3条回答
  •  无人及你
    2021-02-05 11:13

    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}}
    

提交回复
热议问题