Search code examples
javascriptember.jsember-router

Ember.js pre4 router get other controllers


Possible Duplicate:
Accessing controllers from other controllers

In Ember pre2 and before with the old Router style, you could get other controllers from the router, so if I were in a controller called PeopleController I could do something like this

App.PeopleController = Ember.Controller.extend({
     some_computed_property: (function() {
          return this.get('target.otherController.property_i_want');
     }).property('target.otherController.property_i_want')
});

or from a debug console

> App.router.get('otherController.property_i_want')

Both of these worked. Pre4 / the new routing style seems to break this. How do I get this functionality with the new router and pre4?


Solution

  • Try this.controllerFor('other').get('property_i_want')

    See last part of http://emberjs.com/guides/routing/setting-up-a-controller/