我的 Angular 專案中有這項服務
getOfertas(): Observable<Oferta[]> {
return this.http.get<Oferta[]>(`${this.urlWebAPI}/ofertas`)
.pipe(
tap(data=>console.log('OfertasService-get(): ', data)
),
catchError(this.handleError)
)
}
我在我的 Angular Component.ts 中使用的
ofertas:Oferta[]=[];
ngOnInit(): void {
this.dataService.getOfertas()
.pipe(
tap(item=>console.log(item))
)
.subscribe(
data=>{
this.ofertas=data;
this.ofertasOriginal=this.ofertas;
}
)
,err=>console.log(err),
()=>{};
}
}
我想在這個 Component.html 的表格中看到結果
<div class='table-responsive'>
<table class='table'>
<thead>
<tr>
<th>Id</th>
<th>Id Presentada</th>
<th>Descripción</th>
<th>Organismo</th>
<th>Fa Presentación</th>
<th>Presupuesto</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let oferta of ofertas; let index=index">
<td>{{oferta.id}}</td>
<td>{{oferta.idPresentada}}</td>
<td>{{oferta.descripcion}}</td>
<td>{{oferta.id}}</td>
<td>{{oferta.fechaPresentacionFulcrum}}</td>
<td>{{oferta.id}}</td>
</tr>
</tbody>
</table>
</div>
但是我在控制臺中使用從 ASP.NEt Core web API 獲得的資料得到了這個結果,但錯誤顯示

有什么想法嗎?
謝謝
uj5u.com熱心網友回復:
回應本身不是一個陣列,而是包含一個陣列。
您需要將模板更改為
<tr *ngFor="let oferta of ofertas.$values; let index=index">
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/354931.html
標籤:有角的 asp.net核心 asp.net-web-api
