How to access parent(multiple levels) instance controller


#1

Here’s the fiddle https://jsfiddle.net/gouthamvel/68wz1szo/1/

I’m trying to access parent controller property using needs(same with Ember.inject.controller), but its not working out. I’m assuming since level 1 controller is an instance controller. needs is confused on which one to pick as many instances of level1 controller exist.

I can use parentController property but in my real problem the parent controller is multiple levels up the hierarchy so I will end up using alias at every level.

Does anyone know a better way to solve this issue ? please let me know.


#2

I’m assuming since level 1 controller is an instance controller. needs is confused on which one to pick as many instances of level1 controller exist.

Correct.

I wouldn’t use render or ObjectController, as ObjectController is deprecated and I imagine render would naturally be as well.

Here is what you are trying to achieve using components:

I can use parentController property but in my real problem the parent controller is multiple levels up the hierarchy so I will end up using alias at every level.

Feel free to amend my example because I don’t think your example demonstrates this. In my update, are you concerned about passing parent as an attribute?


#3

Thanks, for the new approach.

I think my problem can be solved using components. Do you think I should opt for component based design as much as possible? Is this where ember’s heading?


#4

Yes, I recommend watching @ebryn’s talk on 2.0: https://www.youtube.com/watch?v=U1HEzVWseng