Reputation: 23722
When using Ember.js with AMD/Require.js, I notice that I cannot access my Ember.Application
instance from the template unless I put it in the global scope (which is supposed to be the thing you avoid by using AMD).
Is it possible to define an Ember.Application
without making it global?
My module:
define(['Ember'], function (Ember) {
window.App = Ember.Application.create();
App.MyView = Ember.View.extend({});
});
My template:
{{#view App.MyView }}{{/view}}
Upvotes: 3
Views: 1361
Reputation: 3973
There is a repo hosted here: https://bitbucket.org/cprecourt/ember-requirejs-example/src. This is an extensive application that lets you see how to handle separating your code. Em.Application is always global unless you decide to nest it inside the Ember object (which you are free to do, and the example repo does do it to allow templates to access the application).
Ember already dumps a load of objects into global before your app loads, so I don't see why a single object more in global is going to make a difference (opposed to polluting the Em/Ember global).
Upvotes: 2