In Angular 2, a child component can get its parent component injected through a constructor parameter. Example:
@Component({...})
export class ParentComponen
This post has been solved thanks to Günther. However, I would like to follow up based on the architectural feedback I got.
First and foremost: I completely agree that the TreeNodeComponent use case example is an anti pattern. A data driven component like a tree this should be controlled by data binding. My apologies for this anti pattern.
However, my actual use case (which is more complex to explain) is that I want to develop an advanced dropdown menu. Requirements:
A usage example:
My consideration is that this would be hard to implement using data binding. It's much practical to be able to bind event handlers and include custom components this way.
But I might be wrong! Any opinions about this are highly welcome!