Title: ngProjectedAs not working when used as static host property inside @Component · Issue #55438 · angular/angular · GitHub
Open Graph Title: ngProjectedAs not working when used as static host property inside @Component · Issue #55438 · angular/angular
X Title: ngProjectedAs not working when used as static host property inside @Component · Issue #55438 · angular/angular
Description: Which @angular/* package(s) are the source of the bug? core Is this a regression? No Description https://angular.io/guide/content-projection#projecting-content-in-more-complex-environments This article introduces the ngProjectedAs host a...
Open Graph Description: Which @angular/* package(s) are the source of the bug? core Is this a regression? No Description https://angular.io/guide/content-projection#projecting-content-in-more-complex-environments This art...
X Description: Which @angular/* package(s) are the source of the bug? core Is this a regression? No Description https://angular.io/guide/content-projection#projecting-content-in-more-complex-environments This art...
Opengraph URL: https://github.com/angular/angular/issues/55438
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ngProjectedAs not working when used as static host property inside @Component","articleBody":"### Which @angular/* package(s) are the source of the bug?\r\n\r\ncore\r\n\r\n### Is this a regression?\r\n\r\nNo\r\n\r\n### Description\r\n\r\nhttps://angular.io/guide/content-projection#projecting-content-in-more-complex-environments\r\n\r\nThis article introduces the ngProjectedAs host attribute as a way to manage more complex content projection challenges.\r\n\r\nI believe that if I set this as a static host attribute inside the host property of the @Component this should work as it is a static attribute assigned to the host.\r\n\r\nThe example below demonstrates the issue:\r\n```ts\r\n@Component({\r\n selector: 'app-root',\r\n standalone: true,\r\n imports: [ProjectToComponent, ProjectAsHostComponent],\r\n template: `\r\n \u003ch2>In line ngProjectAs\u003c/h2>\r\n \u003cproject-to>\r\n \u003cdiv ngProjectAs=\"[projectedElement]\">I should be projected\u003c/div>\r\n \u003c/project-to>\r\n\r\n \u003ch2>Static host property ngProjectAs\u003c/h2>\r\n \u003cproject-to>\r\n \u003cproject-as-host/>\r\n \u003c/project-to>\r\n `,\r\n})\r\nexport class App {\r\n name = 'Angular';\r\n}\r\n```\r\nwith project-as-host having the following source code:\r\n```ts\r\nimport { Component } from '@angular/core';\r\n\r\n@Component({\r\n selector: 'project-as-host',\r\n standalone: true,\r\n host: {\r\n ngProjectAs: '[projectedElement]',\r\n },\r\n template: `\r\n\t\t\u003cp>I should be projected\u003c/p>\r\n\t`,\r\n})\r\nexport default class ProjectAsHostComponent {}\r\n```\r\n\r\nA curious observation.\r\nIf I change the host attribute to ngProject and leave out the As, in the html I see the following correct static binding:\r\n```html\r\n\u003cproject-as-host ngproject=\"[projectedElement]\">\u003cp>I should be projected\u003c/p>\u003c/project-as-host>\r\n```\r\n\r\n### Please provide a link to a minimal reproduction of the bug\r\n\r\nhttps://stackblitz.com/edit/stackblitz-starters-tzechz?file=src%2Fmain.ts\r\n\r\n### Please provide the exception or error you saw\r\n\r\n```true\r\nThere is no error. The content is just not projected anywhere.\r\n```\r\n\r\n\r\n### Please provide the environment you discovered this bug in (run `ng version`)\r\n\r\n```true\r\nAngular CLI: 17.3.5\r\nNode: 18.18.0\r\nPackage Manager: npm 10.2.3\r\nOS: linux x64\r\n\r\nAngular: 17.3.5\r\n... animations, cli, common, compiler, compiler-cli, core, forms\r\n... platform-browser, router\r\n\r\nPackage Version\r\n---------------------------------------------------------\r\n@angular-devkit/architect 0.1703.5\r\n@angular-devkit/build-angular 17.3.5\r\n@angular-devkit/core 17.3.5\r\n@angular-devkit/schematics 17.3.5\r\n@schematics/angular 17.3.5\r\nrxjs 7.8.1\r\ntypescript 5.3.3\r\nzone.js 0.14.4\r\n```\r\n\r\n\r\n### Anything else?\r\n\r\nThe motivation for this is to work around content projection with select is currently limited to hard coded strings. This is an issue with what we are trying to achieve for spartan/ui's select component that should ideally allow the user installing the dependency to configure a custom component to be projected as a trigger. More here: https://github.com/goetzrobin/spartan/issues/252","author":{"url":"https://github.com/goetzrobin","@type":"Person","name":"goetzrobin"},"datePublished":"2024-04-19T23:44:00Z","url":"https://github.com/angular/angular/issues/55438"}
| 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:5909959c-235d-adf7-7739-344df16f03da |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A85E:157C65:146078C:1B351D6:6B0130F3 |
| html-safe-nonce | 6e0d42f7a9ce46f7f0bdcf86e075e786d79d5e08bffb8f7610c41139d24c7e97 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBODVFOjE1N0M2NToxNDYwNzhDOjFCMzUxRDY6NkIwMTMwRjMiLCJ2aXNpdG9yX2lkIjoiMjcyNTIxNTY4MjM1MzUwODU5NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 138ed83712162b409231c6f6e351ec2bed7a3507362015e00fd2d7f5255dad3b |
| hovercard-subject-tag | issue:2254252177 |
| 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/55438/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9433c9b2d75c8c73aca0456d3942e5ff6a6b84a064b98e03267578f8eabc0652/angular/angular/issues/55438 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9433c9b2d75c8c73aca0456d3942e5ff6a6b84a064b98e03267578f8eabc0652/angular/angular/issues/55438 |
| og:image:alt | Which @angular/* package(s) are the source of the bug? core Is this a regression? No Description https://angular.io/guide/content-projection#projecting-content-in-more-complex-environments This art... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | goetzrobin |
| 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