Title: Query redesign · Issue #3922 · angular/angular · GitHub
Open Graph Title: Query redesign · Issue #3922 · angular/angular
X Title: Query redesign · Issue #3922 · angular/angular
Description: This is a proposal for a redesign for the query API. It allows a directive to find other directives that are structurally its 'children'. A directive can query the children of the element it is placed on with @ContentChild / @ContentChil...
Open Graph Description: This is a proposal for a redesign for the query API. It allows a directive to find other directives that are structurally its 'children'. A directive can query the children of the element it is pla...
X Description: This is a proposal for a redesign for the query API. It allows a directive to find other directives that are structurally its 'children'. A directive can query the children of the element i...
Opengraph URL: https://github.com/angular/angular/issues/3922
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Query redesign","articleBody":"This is a proposal for a redesign for the query API. It allows a directive to find other directives that are structurally its 'children'.\n- A directive can query the children of the element it is placed on with `@ContentChild` / `@ContentChildren` (used to be @Query) and its view with `@ViewChild` / `@ViewChildren` (used to be @ViewQuery).\n- When using @xxxChild the object received will be the desired element (or null if not found), when using @xxxChildren the object will be an ObservableArray.\n- Queries will be recalculated when a structural change occurs (ng-if, ng-for), @xxxChild will be set to the new value, while @xxxChildren will notify via the observable API.\n- The results will not be injectable, but rather set on declared properties by the framework.\n\nEx:\n\n``` javascript\n@Component(...)\n@View(...) \nclass ListComponent {\n @ContentChild(ItemDirective)\n itemDirective: ItemDirective;\n }\n\n@Component(...)\n@View(...) \nclass ListComponent2 {\n @ViewChildren(ItemDirective)\n itemDirectives: ObservableArray\u003cItemDirective\u003e;\n }\n```\n\nThe children directives will be set before the following callbacks are fired (https://github.com/angular/angular/issues/3863) - `afterContentChecked` for `ContentChild` and `afterViewChecked` for `ViewChild`. \n\nBoth query mechanisms do not go into further into component subviews. `ContentChild / ContentChildren` support configurable visibility as follows :\n- `descendants: true` - all content descendants are considered\n- `descendants: false` - only direct children of the querying directive are considered (default)\n `ViewChildren` has no visibility configuration. Queries always skip the element on which the querying directive lives (similar to `DOM.querySelector`).\n\nImplementation\n- [x] implement lifecycle hooks (https://github.com/angular/angular/issues/3863)\n- [x] hook up query update calls to the new hooks\n- [x] add integration test for view query with var bindings (#3920)\n- [x] remove query from forms API (#3962)\n- [x] using view.elementInjectors internally instead of inj.children tree (closes #3625)\n- [x] add `ContentChildren` and `ViewChildren` (#4237)\n- [x] use Rx.Next for ObservableArray\n- [x] move declaration to @Component field and using setters\n- [x] implement ContentChild and ViewChild\n- [x] remove self visibility from Query \n- [ ] optimize static single child\n- [x] implement dynamic strategy for queryRefs\n\n// cc @mhevery @vsavkin \n","author":{"url":"https://github.com/rkirov","@type":"Person","name":"rkirov"},"datePublished":"2015-08-31T22:41:37.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/3922/angular/issues/3922"}
| 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:82f65229-76f8-b818-7ed5-661c6e449688 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9AC0:3DCA42:38D1D6:4C30C6:6A5FF06F |
| html-safe-nonce | 5c21d836dc4c401e3bd19a5c1f86f655152907b033f1a1d582709560cb3a52a4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QUMwOjNEQ0E0MjozOEQxRDY6NEMzMEM2OjZBNUZGMDZGIiwidmlzaXRvcl9pZCI6IjMwNDUxMTE5MDc0NzUyNTU0MDciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 8eab8b30fbfef090c85d08ab4471399d664979efe727b1bab5e09bc65c5ddfb9 |
| hovercard-subject-tag | issue:104148053 |
| 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/3922/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9c02109fe3d2418bd68a521d6047671274af41bb717edd074f91c17a31145f9f/angular/angular/issues/3922 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9c02109fe3d2418bd68a521d6047671274af41bb717edd074f91c17a31145f9f/angular/angular/issues/3922 |
| og:image:alt | This is a proposal for a redesign for the query API. It allows a directive to find other directives that are structurally its 'children'. A directive can query the children of the element it is pla... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | rkirov |
| hostname | github.com |
| expected-hostname | github.com |
| None | ba296ecd3a3521238fe43b3b3b08cc09207ddc21173e16ee656db03803de8e2b |
| 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 | 6e50fb37e29e4aa0df6386cb485e58b0e3ca97ab |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width