Title: ContentChildren doesn't get children created with NgTemplateOutlet · Issue #14842 · angular/angular · GitHub
Open Graph Title: ContentChildren doesn't get children created with NgTemplateOutlet · Issue #14842 · angular/angular
X Title: ContentChildren doesn't get children created with NgTemplateOutlet · Issue #14842 · angular/angular
Description: Original title: ViewChildren doesn't get children created with NgTemplateOutlet Please see comments below... I'm submitting a ... [x] bug report Current behavior When you use ngTemplateOutlet to render a template passing by input propert...
Open Graph Description: Original title: ViewChildren doesn't get children created with NgTemplateOutlet Please see comments below... I'm submitting a ... [x] bug report Current behavior When you use ngTemplateOutlet to re...
X Description: Original title: ViewChildren doesn't get children created with NgTemplateOutlet Please see comments below... I'm submitting a ... [x] bug report Current behavior When you use ngTemplateOutl...
Opengraph URL: https://github.com/angular/angular/issues/14842
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ContentChildren doesn't get children created with NgTemplateOutlet","articleBody":"Original title: *ViewChildren doesn't get children created with NgTemplateOutlet*\r\n\r\n**Please see comments below...**\r\n\r\n**I'm submitting a ...**\r\n```\r\n[x] bug report\r\n```\r\n\r\n**Current behavior**\r\nWhen you use ngTemplateOutlet to render a template passing by input property ViewChildren don't get or don't find in the redered elements.\r\n\r\n**Expected behavior**\r\nI think ViewChildren should get the elements rendered by ngTemplateOutlet.\r\n\r\n**Minimal reproduction of the problem with instructions**\r\nIn this [plunkr](https://plnkr.co/edit/BHZHcVKuhoP8OzQHIxAR?p=info), on app.ts file, you can see a `Child` component and a `Parent` component, Parent component has an input property called `template1`, this accept a TemplateRef that is rendered using ngTemplateOutlet. `Parent` component has a `ViewChildren` collection to get the `Child` components and shows the length of this collection in the end of template.\r\n\r\nWell, using this component this way:\r\n\r\n```` html\r\n \u003cng-template #template1>\r\n \u003cchild>\u003c/child>\r\n \u003cchild>\u003c/child>\r\n \u003c/ng-template>\r\n \u003cparent [template1]=\"template1\">\u003c/parent>\r\n````\r\n\r\nThe `Parent` component render the two `Child` components but the length of ViewChildren collection is 0. You can uncomment the line 16 of app.ts file to include a static `\u003cchild/>` component in the `Parent` template. Then the collection length is 1.\r\n\r\n**What is the motivation / use case for changing the behavior?**\r\nIt's would be very useful to pass template to components, rows of grids, lines of lists, ...\r\nIn the other hand I have this [plunkr](https://plnkr.co/edit/wFvjrJjNYBLx5sYnJRhm?p=preview) in this case I am rendering `Child` components using a `ngFor`, ViewChildren works fine.\r\nSince both, ngTemplateOutlet and ngForOf, using `viewContainerRef.createEmbeddedView` to render the templates ... why works with ngFor and not with ngTemplateOutlet?\r\nI think that the only reason is that `Child` components come from different component context, but I would like to know it.\r\n\r\n**Please tell us about your environment:**\r\nWindows 10, VisualStudioCode, npm, lite-server\r\n\r\n* **Angular version:** 4.0.0-rc2\r\n\r\n* **Browser:** [all]\r\n \r\n* **Language:** [TypeScript 2.2.1]\r\n","author":{"url":"https://github.com/tolemac","@type":"Person","name":"tolemac"},"datePublished":"2017-03-01T20:14:13Z","url":"https://github.com/angular/angular/issues/14842"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:29fb4954-ef4e-2034-775d-5bafef15dc23 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CF7A:A71F9:D20F15:107EB14:6B013A31 |
| html-safe-nonce | ed919f71306b3768a01480865a1998491e9631241d33561f6a396594d71301de |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRjdBOkE3MUY5OkQyMEYxNToxMDdFQjE0OjZCMDEzQTMxIiwidmlzaXRvcl9pZCI6IjMzOTA4NTYyNDIyMzc4ODA4ODEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | afefbd527bf6b4a43e18545f84613054ce920a789feb73b14108bb7d784b2e93 |
| hovercard-subject-tag | issue:211194920 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/14842/issue_layout |
| twitter:image | https://opengraph.githubassets.com/739f596dac7d118779a93f99223167a2488d4678a4ef16bc5853da260568acb1/angular/angular/issues/14842 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/739f596dac7d118779a93f99223167a2488d4678a4ef16bc5853da260568acb1/angular/angular/issues/14842 |
| og:image:alt | Original title: ViewChildren doesn't get children created with NgTemplateOutlet Please see comments below... I'm submitting a ... [x] bug report Current behavior When you use ngTemplateOutlet to re... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tolemac |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width