Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the outer parent controller from inside an ember component?

Tags:

ember.js

Currently I'm passing a custom keyword into the component like so (as I loop over each model in my array controller)

{{#each thing in controller}}
  {{my-thing foo=controller}}
{{/each}}

Then inside my component I can add a custom attributeBindings and bind to "foo" but I'd like to think I can get access to the parent controller (from inside the component itself)

How else can I get this from inside the component in ember 1.8+ ?

like image 964
Toran Billups Avatar asked Feb 22 '15 17:02

Toran Billups


1 Answers

Check out targetObject:

If the component is currently inserted into the DOM of a parent view, this property will point to the controller of the parent view.

In the Component, you can use this.get('targetObject'); to get the Controller of the parent view.

like image 167
Alex S. Avatar answered Nov 15 '22 11:11

Alex S.