I am using Angular 2.0.1.
I have a component that can accept any other component through <ng-content>- this works fine.
The problem I am facing is when I want to reference a nested component.
If I knew that there <ng-content>would be only one component, I could say:
@ContentChild(MyComponent) dynamicTarget: IMyComponent;but since it can be any component (the only assumption I would make is that any injected component implements a certain interface), it becomes more complicated.
I also tried <ng-content #dynamicTarget'>and then referenced it, saying @ContentChild('dynamicTarget') dynamicTarget: IMyComponent;, but this returns undefined.
Does anyone know how I can tell Angular 2 that this thing is an instance of a component, so that I can try to call a function on it?
To clarify the use case, I have a multi-step wizard that can accept any component as content, and I want to call a function validatein the content (which, again, I would assume that an instance exists)
source
share