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.
let app = Ember.Namespace.NAMESPACES.find(namespace => namespace instanceof Ember.Application)
let router = app.__container__.lookup('service:router');
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?
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.