I have a component that declares some outside html around an <ng-content>
tag. However, if the content is of a specific component class, or if it contains certain tags, I'd like to be able to access those.
For example, in the code below, the component MyComponent
has been set as the content of MyWrapper
. From within MyWrapper
, how can I get the MyComponent
that has been stuck in it?
Example
--Wrapper Template--
...
<ng-content #content></ng-content>
...
--Wrapper Usage--
<my-wrapper>
<my-component></my-component>
</my-wrapper>
My preference would be able to get an object representing the component that was set inside the ng-content
, so I can access it using typescript. But, I'll settle for just being able to get DOM objects. Or, if I'm totally on the wrong track and should be doing this another way, I'll welcome that too.