When using contentChildren in #Angular to access projected elements, by default, it only finds direct children, no descendants 🛑 If you use contentChildren to query a list of projected children, the component will only find them if they are projected as direct children. If you add a container of another nested structure in your projection content, contentChildren will not find the elements you are looking for 🤔 But there is a configuration for this, on contentChildren, you can add a descendants configuration, when you set this to true it will find the elements, but be carefull, because it will look all the way down the DOM tree, so you need to filter or scope correctly when using descendants true ✅
Thank Roberto, so it means it will look through the whole app, not only limited to the component where it is used, is it right ?
Fullstack Developer | Angular & .NET Spezialist | Software for Medical Technology
1moGreat point! Utilizing the `descendants` configuration is essential when dealing with nested structures in Angular. However last weekend I found out that it is possible to use viewChild.required which drops the undefined type. This is really helpful :-)