Title: Make it possible to reason about content to project (content projection and content queries unification) · Issue #37319 · angular/angular · GitHub
Open Graph Title: Make it possible to reason about content to project (content projection and content queries unification) · Issue #37319 · angular/angular
X Title: Make it possible to reason about content to project (content projection and content queries unification) · Issue #37319 · angular/angular
Description: There are multiple use-cases where one would like to reason about content provided to a component (check if content was provided at all, count the number of items etc.). To make the discussion more concrete let's consider the following m...
Open Graph Description: There are multiple use-cases where one would like to reason about content provided to a component (check if content was provided at all, count the number of items etc.). To make the discussion more...
X Description: There are multiple use-cases where one would like to reason about content provided to a component (check if content was provided at all, count the number of items etc.). To make the discussion more...
Opengraph URL: https://github.com/angular/angular/issues/37319
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Make it possible to reason about content to project (content projection and content queries unification)","articleBody":"There are multiple use-cases where one would like to reason about content provided to a component (check if content was provided at all, count the number of items etc.). \r\n\r\nTo make the discussion more concrete let's consider the following markup ([full runnable scenario](https://stackblitz.com/edit/angular-ivy-sumkgl?file=src%2Fapp%2Fapp.component.ts)):\r\n\r\n```html\r\n\u003cmy-container>\r\n \u003cmy-item>\u003c/my-item>\r\n \u003cmy-item>\u003c/my-item> \r\n \u003cmy-item>\u003c/my-item>\r\n\u003c/my-container>\r\n```\r\n\r\nGiven this markup the `\u003cmy-container>` component might want to answer the following questions:\r\n* was content provided at all (existing, popular issue.: #26083)\r\n* how many items were provided (as of today this could be done through content queries only).\r\n\r\nOn top of this the `\u003cmy-container>` implementation might want to do the following (all the provided examples boil down to the ability of projecting items individually):\r\n* wrap each item into some markup;\r\n* project only 2 first items;\r\n* project every second item (or items in 2 separate columns);\r\n* etc. etc.\r\n\r\nAchieving any of the use-cases listed above is very difficult in the current Angular and it steams from the fact that one can't reason (count, pick-up, check presence etc.) about individual items to project. \r\n\r\nWhile content queries can be used, to some degree, to reason about content items individually, the content queries approach has its problems as well:\r\n* we end up with 2 mechanism operating on content (content queries and content projection) - those 2 mechanism have different APIs, different capabilities, need to be learnt separately etc.;\r\n* there is a fundamental mismatch between 2 mechanism: content projection operates on \"blocks\" that can't be reason about (but capture content), while content queries are good with individual items but don't capture content (we can't insert result of a content query into the DOM).\r\n\r\nThis fundamental mismatch between content projection and content queries leads to many surprising situations and use-cases that can't be implemented really. Again, here is a \"typical\" example: https://stackblitz.com/edit/angular-ivy-sumkgl?file=src%2Fapp%2Fapp.component.ts\r\n\r\nIn short: content projection and content queries are good mechanisms while used separately, but as soon as we try to use both mechanisms together we start to bump into serious problems.\r\n\r\nThe idea behind opening this issue is to capture use-cases that are difficult to implement and expose problems where both content queries and content projection are used together. This should open ways to designing a more powerful content projection where it is possible to reason about and project content with one API. To set expectations: there are no immediate implementation plans, we want to capture use-cases and experiment with different APIs first.","author":{"url":"https://github.com/pkozlowski-opensource","@type":"Person","name":"pkozlowski-opensource"},"datePublished":"2020-05-28T10:50:56Z","url":"https://github.com/angular/angular/issues/37319"}
| 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:169307b5-f117-d146-79df-13a790ced58f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A9B4:1F7384:B7E3A6:F489F3:6B00F080 |
| html-safe-nonce | 2af3227fb74e3a0a83002ac834b24a232a146a1d154d79c1f8886ace2a782148 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOUI0OjFGNzM4NDpCN0UzQTY6RjQ4OUYzOjZCMDBGMDgwIiwidmlzaXRvcl9pZCI6IjMxNzY2NDk5NzEwMzAwOTM5NTIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 70eba216078301bea35384e36a2872b8dff23fa93584ca3e6bb2c7ba15af6d82 |
| hovercard-subject-tag | issue:626412470 |
| 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/37319/issue_layout |
| twitter:image | https://opengraph.githubassets.com/799091a2ccb91f9abea4f31ee9b6a9dc2b55e3c2d761240c94db0d46ff0ba6b8/angular/angular/issues/37319 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/799091a2ccb91f9abea4f31ee9b6a9dc2b55e3c2d761240c94db0d46ff0ba6b8/angular/angular/issues/37319 |
| og:image:alt | There are multiple use-cases where one would like to reason about content provided to a component (check if content was provided at all, count the number of items etc.). To make the discussion more... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | pkozlowski-opensource |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc |
| 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 | 9983dd5da06943f833c971dd5b6bc988e2858be5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width