fix(ngFor): give more instructive error when binding to non-iterable

Before, you'd get an error like:

```
EXCEPTION: Cannot find a differ supporting object ‘[object Object]’ in [users in UsersCmp@2:14]
```

Now, you get:

```
EXCEPTION: Cannot find a differ supporting object ‘[object Object]’ of type 'Object'. Did you mean to bind ngFor to an Array? in [users in UsersCmp@2:14]
```
This commit is contained in:
Brian Ford
2016-03-09 12:05:15 -08:00
parent 0898bca939
commit 49527ab495
5 changed files with 35 additions and 6 deletions

View File

@ -62,7 +62,10 @@ export interface Type extends Function {}
export interface ConcreteType extends Type { new (...args): any; }
export function getTypeNameForDebugging(type: Type): string {
return type['name'];
if (type['name']) {
return type['name'];
}
return typeof type;
}