I am trying to access from a child template to its parent data in the previous versions of emberjs this could have be done using the needs keyword:
app.RepositoriesController = Ember.Controller.extend({
needs: "user",
user : Ember.computed.alias("controllers.user");
});
from what I understand with the new ember version this should be done like the following (as the needs keywords became deprecated):
app.RepositoriesController = Ember.Controller.extend({
user: Ember.inject.controller('user')
});
but it doesn't seems to work in my html code I use the following line which is blank:
{{user.name}}
Thanks!
All you need to do is call:
user: Ember.inject.controller()
And ember is smart enough to automatically pick up the correct controller based on the property key.
http://emberjs.com/api/classes/Ember.inject.html#method_controller
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With