Reputation: 597
I'm trying to get a children component of another component, is it possible? For example, I have this QueryList:
@ContentChildren(SysColumn) syscolumns: QueryList<SysColumn>;
It will create a QueryList of all the SysColumns classes instanciated, that's perfectp, but i need to get a list of the child components inside of SysColums... The HTML will be like this:
<parent>
<sys-column>
<child></child>
</sys-column>
<sys-column>
<child></child>
</sys-column>
</parent>
If I do a Foreach of the QueryList it will show the two SysColms, but now I need to have the inner components. How can I achieve it
Upvotes: 1
Views: 229
Reputation: 597
I found the solution here on the angular GitHub: https://github.com/angular/angular/issues/11039#issuecomment-242091301
Upvotes: 0
Reputation: 657268
If you want to query Child components, @ContentChildren()
needs to look like
@ContentChildren(Child, {descendants: true}) children: QueryList<Child>;
{descendants: true}
might be the default anyway (don't remember)
Upvotes: 1