Title: ng-template gets rendered twice during hydration (when anchor comment node is not projected) · Issue #50543 · angular/angular · GitHub
Open Graph Title: ng-template gets rendered twice during hydration (when anchor comment node is not projected) · Issue #50543 · angular/angular
X Title: ng-template gets rendered twice during hydration (when anchor comment node is not projected) · Issue #50543 · angular/angular
Description: Which @angular/* package(s) are the source of the bug? platform-browser Is this a regression? No Description when hydration is enabled and a component uses ngTemplateOutlet to render a template passed from a parent e.g. via ContentChild ...
Open Graph Description: Which @angular/* package(s) are the source of the bug? platform-browser Is this a regression? No Description when hydration is enabled and a component uses ngTemplateOutlet to render a template pas...
X Description: Which @angular/* package(s) are the source of the bug? platform-browser Is this a regression? No Description when hydration is enabled and a component uses ngTemplateOutlet to render a template pas...
Opengraph URL: https://github.com/angular/angular/issues/50543
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ng-template gets rendered twice during hydration (when anchor comment node is not projected)","articleBody":"### Which @angular/* package(s) are the source of the bug?\n\nplatform-browser\n\n### Is this a regression?\n\nNo\n\n### Description\n\nwhen hydration is enabled and a component uses `ngTemplateOutlet` to render a template passed from a parent e.g. via `ContentChild` then its getting rendered twice for the duration of the hydration.\r\n\r\nSo it looks the like this if 'abc' is the template content\r\nreceived from server\r\n`abc`\r\n\r\nduring hydration\r\n`abc abc` \u003c-- this looks sometimes a bit ugly\r\n\r\nafter hydration\r\n`abc`\r\n\r\nSo is it possible that the passed template gets just once rendered during the hydration process?\r\n\r\n\r\nThe relevant code parts for reprodruction:\r\n```\r\n\u003capp-shell>\r\n \u003cng-template #customTemplate>\r\n \u003cp>template\u003c/p>\r\n \u003c/ng-template>\r\n\u003c/app-shell>\r\n```\r\n\r\n```\r\n@Component({\r\n selector: 'app-shell',\r\n template: `\u003cng-container\r\n *ngIf=\"customTemplate\"\r\n [ngTemplateOutlet]=\"customTemplate\"\r\n >\u003c/ng-container>`,\r\n styles: [],\r\n})\r\nexport class ShellComponent {\r\n @ContentChild('customTemplate', { static: true })\r\n customTemplate: TemplateRef\u003cany> | null = null;\r\n}\r\n\r\n```\n\n### Please provide a link to a minimal reproduction of the bug\n\nhttps://github.com/michael-hein/hydration-ng-template\n\n### Please provide the exception or error you saw\n\n```true\nN/A\n```\n\n\n### Please provide the environment you discovered this bug in (run `ng version`)\n\n```true\nAngular CLI: 16.0.4 \r\nNode: 18.16.0\r\nPackage Manager: npm 8.19.3\r\nOS: win32 x64\r\n\r\nAngular: 16.0.4\r\n... animations, cli, common, compiler, compiler-cli, core, forms\r\n... platform-browser, platform-browser-dynamic, platform-server\r\n... router\r\n\r\nPackage Version\r\n---------------------------------------------------------\r\n@angular-devkit/architect 0.1600.4\r\n@angular-devkit/build-angular 16.0.4\r\n@angular-devkit/core 16.0.4\r\n@angular-devkit/schematics 16.0.4\r\n@nguniversal/builders 16.0.2\r\n@nguniversal/express-engine 16.0.2\r\n@schematics/angular 16.0.4\r\nrxjs 7.8.1\r\ntypescript 4.9.5\n```\n\n\n### Anything else?\n\n_No response_","author":{"url":"https://github.com/michael-hein","@type":"Person","name":"michael-hein"},"datePublished":"2023-06-01T21:03:07Z","url":"https://github.com/angular/angular/issues/50543"}
| 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:69331ba7-bdcb-75c8-281b-369855e097ce |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B1AE:10531B:815BA3:A4DAFD:6B0121D8 |
| html-safe-nonce | f7fe11d3a4e1b0b42b481eddb359f5a4a3b07573e994428e8ec4648e22ba4d49 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMUFFOjEwNTMxQjo4MTVCQTM6QTREQUZEOjZCMDEyMUQ4IiwidmlzaXRvcl9pZCI6IjMyMTk4NTU5NTQ3NTM0Mjk5NzYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c965d5b7b95c65ecaba50f5ee7c4bef839b7fd07406121c54360e9eb3dd3de71 |
| hovercard-subject-tag | issue:1737091586 |
| 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/50543/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fff7aa5f54bb556338f952138f0c63c773a2cb393f8dc32b0b3bcd0b28e28efa/angular/angular/issues/50543 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fff7aa5f54bb556338f952138f0c63c773a2cb393f8dc32b0b3bcd0b28e28efa/angular/angular/issues/50543 |
| og:image:alt | Which @angular/* package(s) are the source of the bug? platform-browser Is this a regression? No Description when hydration is enabled and a component uses ngTemplateOutlet to render a template pas... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | michael-hein |
| 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