# How to access Ember container from the window?

**URL:** <https://discuss.emberjs.com/t/how-to-access-ember-container-from-the-window/14708>\
**Category:** Questions\
**Created:** [May 7, 2018, 8:47pm UTC](https://discuss.emberjs.com/t/how-to-access-ember-container-from-the-window/14708 "2018-05-07T20:47:25Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![robert-j-webb](https://avatars.discourse-cdn.com/v4/letter/r/ebca7d/32.png) [@robert-j-webb](https://discuss.emberjs.com/u/robert-j-webb)\
**Post date:** [May 7, 2018, 8:47pm UTC](https://discuss.emberjs.com/t/how-to-access-ember-container-from-the-window/14708/1 "2018-05-07T20:47:25Z")

</div>

Hi!

I found I had this as a question and I found the answer with some help. I hope this helps someone one day. You probably shouldn’t do this by the way - accessing private methods generally is a bad practice, but it can be a life saver if you have to make a deadline.

```nohighlight
let app = Ember.Namespace.NAMESPACES.find(namespace => namespace instanceof Ember.Application)
let router = app. __container__.lookup('service:router');

```

---

<div class="post-metadata">

**Author:** ![rondale\_sc](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/rondale_sc/32/13883_2.png) [@rondale\_sc](https://discuss.emberjs.com/u/rondale_sc)\
**Post date:** [May 8, 2018, 6:17pm UTC](https://discuss.emberjs.com/t/how-to-access-ember-container-from-the-window/14708/2 "2018-05-08T18:17:34Z")

</div>

Thanks for writing this up!

I do think it is worth discussing how we could make this available in a sane way for debugging purposes. Perhaps a flag (whether it be environment or elsewhere) to tell Ember that we are entering debug mode and want access to the application in the devtools perhaps even when inspector isn’t available. Or some other debugging API.

Does anyone have any thoughts on how that might work?

---

<div class="post-metadata">

**Author:** ![Gaurav0](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/gaurav0/32/4704_2.png) [@Gaurav0](https://discuss.emberjs.com/u/Gaurav0)\
**Post date:** [May 8, 2018, 6:21pm UTC](https://discuss.emberjs.com/t/how-to-access-ember-container-from-the-window/14708/3 "2018-05-08T18:21:23Z")

</div>

Just install: [ember-export-application-global](https://github.com/ember-cli/ember-export-application-global)

---

<div class="post-metadata">

**Author:** ![robert-j-webb](https://avatars.discourse-cdn.com/v4/letter/r/ebca7d/32.png) [@robert-j-webb](https://discuss.emberjs.com/u/robert-j-webb)\
**Post date:** [May 8, 2018, 6:31pm UTC](https://discuss.emberjs.com/t/how-to-access-ember-container-from-the-window/14708/4 "2018-05-08T18:31:48Z")

</div>

Maybe that if your build isn’t production, then you can always access the application and thus the container with something like `ember.app`?

It’s true that it’s not a lot of work to inject App into window using an initializer, but it’s definitely something that newcomers wouldn’t know to do. Additionally, there’s a lack of documentation about the container in general, which is a shame, because it’s a huge part of understanding how Ember actually works.

---

<div class="post-metadata">

**Author:** ![rondale\_sc](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/rondale_sc/32/13883_2.png) [@rondale\_sc](https://discuss.emberjs.com/u/rondale_sc)\
**Post date:** [May 8, 2018, 6:34pm UTC](https://discuss.emberjs.com/t/how-to-access-ember-container-from-the-window/14708/5 "2018-05-08T18:34:11Z")

</div>

> [@Gaurav0](#):
>
> ember-export-application-global

I didn’t know about this actually. Very neat! Thanks @Gaurav0!

---

<div class="post-metadata">

**Author:** ![Gaurav0](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/gaurav0/32/4704_2.png) [@Gaurav0](https://discuss.emberjs.com/u/Gaurav0)\
**Post date:** [May 8, 2018, 6:41pm UTC](https://discuss.emberjs.com/t/how-to-access-ember-container-from-the-window/14708/6 "2018-05-08T18:41:02Z")

</div>

> [@robert-j-webb](#):
>
> Additionally, there’s a lack of documentation about the container in general, which is a shame, because it’s a huge part of understanding how Ember actually works.

How would you improve this: [Dependency Injection - Application Concerns - Ember Guides](https://guides.emberjs.com/v3.1.0/applications/dependency-injection)

---

<div class="post-metadata">

**Author:** ![HeroicEric](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/heroiceric/32/18432_2.png) [@HeroicEric](https://discuss.emberjs.com/u/HeroicEric)\
**Post date:** [May 8, 2018, 6:50pm UTC](https://discuss.emberjs.com/t/how-to-access-ember-container-from-the-window/14708/7 "2018-05-08T18:50:59Z")

</div>

You can also use the [Ember Inspector](https://chrome.google.com/webstore/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi?hl=en) to view and grab stuff that is is in the container.

[![](http://g.recordit.co/jy9b4zZsP8.gif) ](http://g.recordit.co/jy9b4zZsP8.gif)
