Unable to use ContentChildren with ngForTemplate
See original GitHub issueI’m submitting a … (check one with “x”)
[x] 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
Getting directives with @ContentChildren
does not work when the directives were created using ngForTemplate
.
Expected behavior
Directives inside repeated templates using ngForTemplate
should be picked up by @ContentChildren
like they would if you were using ng-content
.
Minimal reproduction of the problem with instructions https://plnkr.co/edit/pt3fgjvL7yREdHKWl8IZ?p=preview
Check src/app.ts
. You’ll see that the Marker
directive is being repeated by the template passed to Repeater
, but Repeater
cannot use @ContentChildren
to query for Marker
s.
What is the motivation / use case for changing the behavior?
In general, this seems like it should work. My specific use case is making a pair of components, each that use ngForTemplate
with one used inside the others template. Together they allow filtering of a collection whose items have sub-items. One feature is that if all items have been filtered out (IE, no matching results) a message should be shown. I would assume the way to do this would be to query for items from the parent and subscribe to changes.
Please tell us about your environment: Reproducible in Plunker.
- Angular version: 2.0.X 2.0.1
- Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ] Tested in Chrome
- Language: TypeScript 2
- Node (for AoT issues):
node --version
=
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (1 by maintainers)
I think I ran into this while exploring using
ViewChildren
/ContentChildren
within custom structural directives. It appearsViewChildren
andContentChildren
can’t see into views created bycreateEmbeddedView
.Plunker here. Parent can’t see a grandchild in either ViewChildren or ContentChildren. And a directive on the Child cannot see anything except a TemplateRef (see console logs).
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.