In development mode, items is an array but after I deploy the app, it turns 
into an object and I get the following error in the console:
Cannot find a differ supporting object '[object Object]' of type 'object'. 
NgFor only supports binding to Iterables such as Arrays.

In the component:

items = [];


getStorageItems(): any[] {
    try {
     return JSON.parse(localStorage.getItem('items'));
    } catch(err) {
     console.warn(err);
     return [];
    }
}


ngOnInit(): void {
   this.items = this.getStorageItems();
 }




In the HTML:

<tr *ngFor="let item of items">
<td>{{item.quantity}} </td>
<td>{{item.product_name }}</td>
</tr>





 

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/angular/6b399f7e-8efc-4838-b7e3-a36f61d54cado%40googlegroups.com.

Reply via email to