Title: Missing forwardRef in Query/ViewQuery should throw · Issue #4174 · angular/angular · GitHub
Open Graph Title: Missing forwardRef in Query/ViewQuery should throw · Issue #4174 · angular/angular
X Title: Missing forwardRef in Query/ViewQuery should throw · Issue #4174 · angular/angular
Description: Consider the following code @Component({selector: 'accordion'}) @View({ template: `
Open Graph Description: Consider the following code @Component({selector: 'accordion'}) @View({ template: `
X Description: Consider the following code @Component({selector: 'accordion'}) @View({ template: ` <accordion-item></accordion-item> <accordion-item></accordion-item>`, directives ...
Opengraph URL: https://github.com/angular/angular/issues/4174
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Missing forwardRef in Query/ViewQuery should throw","articleBody":"Consider the following code\n\n``` javascript\n@Component({selector: 'accordion'})\n@View({\n template: `\n \u003caccordion-item\u003e\u003c/accordion-item\u003e\n \u003caccordion-item\u003e\u003c/accordion-item\u003e`,\n directives : [forwardRef(() =\u003e AccordionItem)]\n})\nexport class Accordion implements OnInit {\n constructor(el: ElementRef, @ViewQuery(AccordionItem) items:QueryList\u003cAccordionItem\u003e) {\n this.items = items;\n }\n onInit() {\n console.log(this.items);\n }\n}\n\n@Component({selector: 'accordion-item'})\n@View({template: `...`})\nexport class AccordionItem {}\n```\n\nThis works, but `items` returns 0 results, which is wierd since there are two children (see plnkr below). The problem here is a missing `forwardRef`.\n\nIf you remove `forwardRef` from the `directives` property in `Accordion` you'll get this error message. Pretty useful.\n\n```\nUnexpected directive value 'undefined' on the View of component 'Accordion'\n```\n\nBut if you miss `forwardRef` in `@ViewQuery` instead of an error you'll get 0 results, while it should throw a similar error to the above one.\n\nSee [repro](http://plnkr.co/edit/MmRqUP?p=preview), switch between the constructors in `Accordion` class and you'll see that no errors are thrown but the length of the results changes.\n\nPS: The title includes `Query` which I didn't test, but I'm assuming that both works similar.\n","author":{"url":"https://github.com/ericmartinezr","@type":"Person","name":"ericmartinezr"},"datePublished":"2015-09-14T12:52:35.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/4174/angular/issues/4174"}
| 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:f30f83b8-a382-5bfe-b69e-7956b72ac73e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 93A8:1DDBFC:41D502:57AF2F:6A5FC97C |
| html-safe-nonce | 3387ac0653b0b7aeca6418302692cf2fa4b0e356a9b661a5f37d4c4dc9b42cab |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5M0E4OjFEREJGQzo0MUQ1MDI6NTdBRjJGOjZBNUZDOTdDIiwidmlzaXRvcl9pZCI6IjY3NDc4ODU5NjAxOTY3NzAxNzIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b26169021a33d19301a2a7d25ba61acce02dfe731c14f015608fdd93ada99de3 |
| hovercard-subject-tag | issue:106334157 |
| 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/4174/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9265b778ccd9a4a3f03b1dcc1a5e1067a359280b295d2db0e004214c336e445d/angular/angular/issues/4174 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9265b778ccd9a4a3f03b1dcc1a5e1067a359280b295d2db0e004214c336e445d/angular/angular/issues/4174 |
| og:image:alt | Consider the following code @Component({selector: 'accordion'}) @View({ template: ` |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ericmartinezr |
| hostname | github.com |
| expected-hostname | github.com |
| None | 8b098704642cd5473d3dc9d5d8023399a68de27a0492776c4517d75af6710ead |
| 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 | d9cb40632285451ad16923c07a6f2debe8279086 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width