In a regular emberjs app you can do
App.__container__.lookup("controller:application")
How can I achieve this is the latest version of ember-cli? I can't see any global application object to refer to.
In a regular emberjs app you can do
App.__container__.lookup("controller:application")
How can I achieve this is the latest version of ember-cli? I can't see any global application object to refer to.
Say you generated your app like this:
ember new kittens
Your debug statement would be:
Kittens.__container__.lookup("component:bootstrap-datepicker")
In Ember CLI when you define an initializer you can do something like:
ember generate initializer my-cool-init
And in the file: app/initializers/my-cool-init.js
have something like:
export default {
name: 'my-cool-init',
initialize: function initialize(container/*, application*/) {
var foobar = container.lookup('controller:application');
// inject or preload stuff etc
}
};
http://emberjs.com/api/classes/Ember.Application.html#toc_initializers
http://emberjs.com/guides/understanding-ember/dependency-injection-and-service-lookup/
ember-export-application-global
addon to expose your app as a global variableCheck out the Ember Inspector on the Chrome web store. It is a Chrome extension that provides debugging and inspection tools for your Ember app.
You can visually access the container, your current view hierarchy, a list of your Ember-Data store's contents, etc.
For example, if you open the inspector on discuss.emberjs.com you can see that there are 11 controllers and you can inspect each one to see their attributes. You can even send the objects to the console so you can play with them programmatically.
ember-export-application-global
The other way is to use the ember-export-application-global ember-cli addon package. This package sets a global variable that contains the reference to your application. This allows you to access the container the way you originally mentioned.