Option 1: reopenController / Component Classes
The easiest way is to reopenadd the property to all controllers / components. If you do this, you can use rootURLin any template without any changes.
import Ember from 'ember';
import ENV from '../config/environment'
Ember.Controller.reopen({
rootUrl: ENV.rootURL,
});
Ember.Component.reopen({
rootUrl: ENV.rootURL,
});
Option 2: Inheriting the controller / component
If you want to limit the scope of changes, you can define the attribute rootURLin the base controller / component, such as application.js:
import ENV from '../config/environment'
export default Ember.Controller.extend({
rootURL: ENV.rootURL,
});
Then in your other controllers / components extend this base class and rootURLwill work in the corresponding templates:
import ApplicationController from 'application';
export default ApplicationController.extend({
});
Option 3: Controller / Mixin Component
, rootURL. Mixin:
import Ember from 'ember';
import ENV from '../config/environment';
export default Ember.Mixin.create({
rootURL: ENV.rootURL,
});
Mixin /, rootURL :
import Ember from 'ember';
import WithRootMixin from '../mixins/with-root';
export default Ember.Controller.extend(WithRootMixin, {
});