Skip to content

low hanging fruit: the error messaging for ngFor unable to iterate objects #28240

@activedecay

Description

@activedecay

🐞 bug report

Affected Package

The issue is caused by package @angular/core

Is this a regression?

No, this is a developer experience issue.

Description

You could easily detect when the developer wants to use an object, but passed the object to ngFor without using the `| keyvalue` pipe

I would like to see the keyvalue pipe mentioned in the error message, something like: "NgFor only supports binding to Iterables such as Arrays. Did you mean to use the keyvalue pipe? See doc link here"

🔬 Minimal Reproduction

https://angular-issue-repro2-qkrgwg.stackblitz.io

🔥 Exception or Error



Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.

🌍 Your Environment

Angular Version:


Angular CLI: 7.1.4
Node: 8.12.0
OS: linux x64
Angular: 7.1.4
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.11.4
@angular-devkit/build-angular     0.11.4
@angular-devkit/build-optimizer   0.11.4
@angular-devkit/build-webpack     0.11.4
@angular-devkit/core              7.1.4
@angular-devkit/schematics        7.1.4
@ngtools/webpack                  7.1.4
@schematics/angular               7.1.4
@schematics/update                0.11.4
rxjs                              6.3.3
typescript                        3.1.6
webpack                           4.23.1

Anything else relevant?
This is really low-hanging fruit. Why make developers search the universe for something you know they probably wanted to do?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions