Skip to content

Add the descendants option to ContentChild聽#31921

Closed

Description

@the-avid-engineer

馃殌 feature request

Relevant Package

@angular/core

Description

Similar but opposite to how the ContentChildren decorator has descendants option to query all descendants, I would like ContentChild to have an option to query only direct descendants.

Describe the solution you'd like

  1. Add descendants as a metadata property for ContentChild
  2. If descendants is true or undefined, query all descendants (preserves current behavior)
  3. If descendants is false, query only direct descendants

Activity

  1. the-avid-engineer commented on Jul 30, 2019

    @the-avid-engineer
    Author

    The expected behavior, for example, would be that a component (my-component) which may or may not expect a content child directive (my-directive) will not catch said content child directive from the nested component.

    I can make a working example if this pseudo-example doesn't explain very well

    <my-component>
        <my-component>
            <ng-template my-directive></ng-template>
        </my-component>
    
        <ng-template my-directive></ng-template>
    </my-component>
    

    VS

    <my-component>
        <my-component>
            <ng-template my-directive></ng-template>
        </my-component>
    </my-component>
    
  2. added this to the needsTriage milestone on Jul 31, 2019
  3. added
    featureLabel used to distinguish feature request from other issues
    on Aug 1, 2019
  4. modified the milestones: needsTriage, Backlog on Aug 1, 2019
  5. pkozlowski-opensource commented on Sep 17, 2019

    @pkozlowski-opensource
    Member

    Yep, we should definitively add the descendants option for ContentChild, was bitten by the lack of it several times already!

  6. changed the title [-]ContentChild - Direct Descendants Only[/-] [+]Add the descendants option to ContentChild[/+] on Mar 27, 2020
  7. angular-robot commented on Jun 4, 2021

    @angular-robot
    Contributor

    Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.

    Find more details about Angular's feature request process in our documentation.

  8. angular-robot commented on Jun 24, 2021

    @angular-robot
    Contributor

    Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.

    We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.

    You can find more details about the feature request process in our documentation.

  9. the-avid-engineer commented on Jun 24, 2021

    @the-avid-engineer
    Author

    It would be nice if the bot posted a link to the poll itself. I had no idea where to vote.

  10. 1 remaining item

  11. the-avid-engineer commented on Jun 24, 2021

    @the-avid-engineer
    Author

    I don't see any links in the documentation.

  12. the-avid-engineer commented on Jun 24, 2021

    @the-avid-engineer
    Author

    Is the voting just done on this issue?

  13. Airblader commented on Jun 24, 2021

    @Airblader
    Contributor

    Yes, it's done using reactions on the issue.

  14. angular-robot commented on Jul 24, 2021

    @angular-robot
    Contributor

    Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.

    We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.

    You can find more details about the feature request process in our documentation.

  15. Xriuk commented on May 26, 2022

    @Xriuk

    Is this not considered? If someone has optional templates with nested components the parent can pick children templates and consider them like its own, which is wrong

  16. angular-automatic-lock-bot commented on Aug 1, 2022

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  17. locked and limited conversation to collaborators on Aug 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions