I think the method controllerFor
should be available in this event:
App.ApplicationRoute = Ember.Route.extend
events:
someAction: (user) ->
console.log this.controllerFor("currentUser").get("name")
Update in response to the questions in the comments:
It all depends on what you want to do. Worrying about DRY on such a basic method, does not make much sense imho.
In your kudos left case I would do this:
App.ApplicationRoute = Ember.Route.extend
events:
someAction: (user) ->
this.controllerFor("currentUser").decrementKudos();
// implement the decrementKudos in your controller
But I guess storing this one controller should also work, if this is too much code for you:
App.ApplicationRoute = Ember.Route.extend
currentUserCon : this.controllerFor("currentUser")
events:
someAction: (user) ->
this.currentUserCon.decrementKudos();
// implement the decrementKudos in your controller
name = this.controllerFor('currentUser').get 'name'
return "hello, #{name}
is it possible? Accessing controllers in such a way many times is not DRY :) – Nike