How are you using AMD with Ember.js?

When using Ember.js with AMD / Require.js, I notice that I cannot access the instance Ember.Application

from the template unless I put it in the global scope (which AMD is supposed to avoid).

Can it be defined 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}}

      

+3


source to share


1 answer


The repo is located here: https://bitbucket.org/cprecourt/ember-requirejs-example/src . This is an extensive application that lets you see how to handle code splitting. Em.Application is always global unless you choose to nest it in an Ember object (which you can do, and the repo example does this to allow templates to reference the application).



Ember already loads a load of objects into the global scope before your app loads, so I don't understand why one more object globally would matter (as opposed to Em / Ember pollution globally).

+2


source







All Articles