In Angular 2, a child component can get its parent component injected through a constructor parameter. Example:
@Component({...})
export class ParentComponen
Angular2 looks into the current injector for a provider. In your case, TreeNodeComponent corresponds to the component itself.
The parent component instance is located into the parent injector.
I think that you could try to inject an Injector class to have access to the parent injector and then get the instance of the parent component. Something like that:
@Component({
(...)
})
export class TreeNodeComponent {
constructor(injector:Injector) {
let parentInjector = injector.parent;
let parent = patentInjector.get(TreeNodeComponent);
}
}
See this link for the documentation of the Injector class:
That said, I think that the Gunter's comment about binding and shared service is particularly relevant...