Reputation: 2042
I have some properties on my parent controller that I want my child controller to have access to.
I want to access it like so:
App.ApplicationController = Ember.ObjectController.extend({
prop1: "someProp",
prop2: "someotherProp",
needs: ["child"]
});
App.ChildController = Ember.ObjectController.extend({
prop1: Ember.computed.alias("parentController.prop1"),
prop2: Ember.computed.alias("parentController.prop2"),
});
How do I access those properties?
--edit--- Does it assume there will always be a single instance of the controller I need?
Upvotes: 2
Views: 1830
Reputation: 1395
To access something in the needs array you use this.get('controllers.some_controller'). I think the above is slightly backwards as you want the child to have access to the application controller.
App.ChildController = Ember.ObjectController.extend({
needs: ['application']
prop1: Ember.computed.alias("controllers.application.prop1"),
prop2: Ember.computed.alias("controllers.application.prop2"),
});
Upvotes: 4