question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@ContentChildren not populating from parent <ng-content>

See original GitHub issue
[*] bug report => search github for a similar issue or PR before submitting
[ ] 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 does not seem to work on Parent <ng-content> containers. Even if the ng-content is a child of the component.

Expected behavior I expect that ContentChildren is filled if it is a child of the component

Minimal reproduction of the problem with instructions https://plnkr.co/edit/J5itJmDfwKwtBsG6IveP?p=preview

Main HTML:

<div>
  <child>
    <test></test>
    <test></test>
    <test></test>
  </child>
  <br><br>
  <parent>
    <test></test>
    <test></test>
    <test></test>
  </parent>
</div>

Child Component:

<h2>Child</h2>
<parent>
  <ng-content></ng-content>
</parent>

Parent Component:

<h3>Parent</h3>
<ng-content></ng-content>
<div class='length'>Line count : {{length}}</div>

Please tell us about your environment: Windows, Angular4

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:38
  • Comments:18 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
ReneWerner87commented, Jul 8, 2020

bug is still open in angular 9 and 10 … please solve it

6reactions
mkurciuscommented, Jul 27, 2018

Any news on this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular2 @ContentChildren not populated inside parent <ng ...
@ContentChildren does not seem to work on Parent <ng-content> containers. Even if the content is a child of the component.
Read more >
This is how I finally understood Content Projection in Angular
Content Projection in simple words is giving a developer the power to insert content from a parent ComponentB into its child ComponentA.
Read more >
ViewChildren & ContentChildren • Angular - codecraft.tv
We render in a tree down approach so when a parent component is getting constructed it means the children are not yet created....
Read more >
Angular:3 ways you can pass templates from parent to child ...
Instead I would directly pass the html from parent to child component. Let's see how this works. Below is the gist of the...
Read more >
Angular - Ovio.org
Tasks & Issues ; 18. 31. #16299. @ContentChildren not populating from parent <ng-content> · Small ; 12. 1. #36086. Service Worker "Quota exceeded"...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found