How to get an instance of a controller in Ember.js?

Denzo picture Denzo · Oct 27, 2012 · Viewed 13.4k times · Source

I'm trying to access an instance of a controller that has been wired automatically using App.initialize();

I've tried the below but it returns a Class not an instance.

Ember.get('App.router.invitesController')

Answer

Emerson picture Emerson · Mar 14, 2013

I have a quick post about this exact subject on my Blog. It's a little big of a different method, but seems to work well for Ember.js RC1.

Check it out at: http://emersonlackey.com/article/emberjs-instance-of-controller-and-views

The basic idea is to do something like:

var myController = window.App.__container__.lookup('controller:Posts');