【发布时间】:2020-05-04 17:07:39
【问题描述】:
我正在尝试从我的 API 中获取值,但我无法在 ion-list 中显示它们。
错误截图:
正如您在图片中看到的,我从我的 API 中获取了数据,但我可以在 ion-list 中显示它们。
HTML 是这样的
<ion-list>
<ion-item *ngFor="let item of (results | async)">
<ion-label text-wrap>{{item.nombreProducto}}</ion-label>
<ion-button color="light"><img src="../../assets/icon/binoculars.png" alt="" (click)="presentarModal()" item-end></ion-button>
<ion-button color="light"><img src="../../assets/icon/cart.png" alt="" (click)="addCart()" item-end></ion-button>
</ion-item>
我创建了一个服务,它有一个名为 getAll 的方法
getAll(): Observable<any>{
return this.http.get(`${this.url}`).pipe(
map(results=>{
console.log('Data', results);
return results['Data'];
})
);
}
在我的 home.page.ts 中,getAll 方法包含这个
getAll(){
this.results = this.productService.getAll();
}
【问题讨论】:
-
响应数据是数组吗?