This error occurs when using a *ngFor loop on an object in Angular.
You can fix this by creating the following pipe. Using this, you transform the object into an array on runtime
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'objectToArray',
})
export class ObjectToArrayPipe implements PipeTransform {
// The object parameter represents the values of the properties or index.
transform = (objects: any = []) => {
return Object.values(objects);
}
}
You can now use:
<div *ngFor="let review of (book.reviews|objectToArray)">
{{ review.id }}
</div>
I changed this original fix on Stackexchange a bit, using the newer strict typescript syntax.