Using this example: jsbin
Where would I put this line of code:
App.name = \'White\'
in the EAK file structure so that it will rende
Putting this in initializers is great but if your app is not using much global data or just need a flag, can use it directly :
window.App = Ember.Application.create(
ready: ->
this.register('current:view', window.current_view, {instantiate: false});
this.inject('controller', 'isCurrentView', 'current:view');
rootElement: '#ember-app'
)
Now you access {{isCurrentView}} in all templates
I'm not sure if this is the right way. But generally EAK tries to avoid polluting the global namespace. So a method to have globals accessible every where is to use initializers to register a globals dependency and inject them to all the controllers. This is the same way ember data injects the store to the controller.
Inside app/initializers
create global.js
file
var globals = Ember.Object.extend({
name: 'Edgar Allen Poe'
});
export default {
name: "Globals",
initialize: function(container, application) {
container.typeInjection('component', 'store', 'store:main');
application.register('global:variables', globals, {singleton: true});
application.inject('controller', 'globals', 'global:variables');
}
};
This will inject the globals to all the controllers. You can refer it in a template like
{{globals.name}}