I am new to ionic 3 and angular. Basically I wanted to create a list with header (data from MySQL database through PHP API). The header will display the category while the items will go to ion-item section.
However when I try to call the 2nd ngFor it throws me error as shown below in the picture. I notice a lot people use GET method while I am using POST method which are harder to find solution out there. Please enlighten, thanks in advance.
JSON
home.ts
this.storage.get('username').then((val) => {
let headers: any = new HttpHeaders({ 'Content-Type': 'application/x-www-form-urlencoded' }),
options: any = { "username": val },
url: any = "path_to_my_api";
this.http.post(url, options, headers)
.subscribe((data: any) => {
this.prods = data.products;
},
(error: any) => {
console.log(error);
});
});
home.html
<ion-list *ngFor="let prod of prods | async">
<ion-list-header>
{{prod.category}}
</ion-list-header>
<ion-item *ngFor="let myitem of prod.item | async">
<ion-avatar item-start>
</ion-avatar>
<h2>haha{{myitem.code}}</h2>
</ion-item>
</ion-list>
