Skip to content

@ContentChildren can select host component as well #10098

Closed
@jack-guy

Description

@jack-guy

I'm submitting a ... (check one with "x")

[ x ] bug report
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior
@ContentChildren will select the host component if the component selector matches it.

<foo the-root>
   <foo></foo>
   <foo></foo>
   <foo></foo>
</foo>

And for the-root

@ContentChildren(FooComponent) foos;
assert(foos.length === 4);

Expected/desired behavior
The foo host component should not be selected.

assert(foos.length === 3);

Reproduction of the problem
https://plnkr.co/edit/E7D0nMdHnPr0OxfxzysB?p=preview

What is the motivation / use case for changing the behavior?
Semantically, one would expect the selection of @ContentChildren to be only strict descendants.

Please tell us about your environment:

  • Angular version: 2.0.0-rc.0
  • Browser: all
  • Language: all

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions