Title: fix: better error messages for NgFor · Issue #14641 · angular/angular · GitHub
Open Graph Title: fix: better error messages for NgFor · Issue #14641 · angular/angular
X Title: fix: better error messages for NgFor · Issue #14641 · angular/angular
Description: I'm submitting a ... (check one with "x") [x] bug report => search github for a similar issue or PR before submitting [ ] feature request [ ] support request Current behavior While there have been a lot of improvements in the error messa...
Open Graph Description: I'm submitting a ... (check one with "x") [x] bug report => search github for a similar issue or PR before submitting [ ] feature request [ ] support request Current behavior While there have been ...
X Description: I'm submitting a ... (check one with "x") [x] bug report => search github for a similar issue or PR before submitting [ ] feature request [ ] support request Current behavior While...
Opengraph URL: https://github.com/angular/angular/issues/14641
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"fix: better error messages for NgFor","articleBody":"**I'm submitting a ...** (check one with \"x\")\r\n\r\n[x] bug report => search github for a similar issue or PR before submitting\r\n[ ] feature request\r\n[ ] support request\r\n\r\n**Current behavior**\r\nWhile there have been a lot of improvements in the error messages space in Angular, it turns out that there's one case left that can causes many hours of debugging, because the error message is confusing.\r\n\r\nWhen forgetting the `let` keyword in `NgFor`'s micro syntax, that error message points the developer in a wrong direction. **Basically, doing this**:\r\n\r\n```\r\n\u003cANY *ngFor=\"item of items\">\u003c/ANY>\r\n```\r\n\r\nThrows this error:\r\n\r\n```\r\nCan't bind to 'ngFor' since it isn't a known property of 'ANY'.\r\n1. If 'ANY' is an Angular component and it has 'ngFor' input, then verify that it is part of this module.\r\n2. If 'ANY' is a Web Component then add \"CUSTOM_ELEMENTS_SCHEMA\" to the '@NgModule.schemas' of this component to suppress this message.\r\n```\r\n\r\nThis error messages usually occurs when one forgets to add/export a directive/component (in this case `NgFor`), but the actually issue is that the developer forgot the `let` keyword in the micro syntax.\r\n\r\nUnfortunately this caused me once 1.5 hours of debugging and wondering why Angular thinks I haven't declared `NgFor` anywhere, while it is in fact properly setup.\r\n\r\nI'm seeing more and more people running into this, so I thought it's worth bringing up.\r\n\r\n**Expected behavior**\r\nIt would be cool if we can throw a more specific error message, or maybe extend the existing one to tell the developer that she needs to double-check the micro syntax.\r\n\r\n**Plunker for reproduction\r\n\r\nhttps://plnkr.co/edit/SAI2cYUjuiVXcg4sL8vz?p=preview (check the console)\r\n\r\n* **Angular version:** 2.x.\r\n","author":{"url":"https://github.com/0x-r4bbit","@type":"Person","name":"0x-r4bbit"},"datePublished":"2017-02-22T12:09:41Z","url":"https://github.com/angular/angular/issues/14641"}
| 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:f275e050-de47-a437-5472-ef0f54035f8c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A7AA:29AEE8:ABC583:E69403:6B00EFD4 |
| html-safe-nonce | 85cf8b826a145c7b096755d384e56b744edb04353aa47fe57b7c3732d7e930aa |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBN0FBOjI5QUVFODpBQkM1ODM6RTY5NDAzOjZCMDBFRkQ0IiwidmlzaXRvcl9pZCI6IjQ5MDMxNTY3NTE2MzA2NTk1NDEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 2a48bd0311e867ffbe9222ea19fc8d6f06cbed82f023ef854a435c357f327887 |
| hovercard-subject-tag | issue:209435769 |
| 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/14641/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0864d401e7b35aa9b478c2309fadb60cbdc08becd6b91856fe6f8f9f92687a10/angular/angular/issues/14641 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0864d401e7b35aa9b478c2309fadb60cbdc08becd6b91856fe6f8f9f92687a10/angular/angular/issues/14641 |
| og:image:alt | I'm submitting a ... (check one with "x") [x] bug report => search github for a similar issue or PR before submitting [ ] feature request [ ] support request Current behavior While there have been ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | 0x-r4bbit |
| 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