我有一个名为 rows 的空数组,我想用 *ngFor 显示它。在数组的每一行上,我传递来自 http 请求的响应。所有的http请求都是按顺序调用的。即使正确输入了数组,*ngFor 也永远不会更新。我想在收到请求响应时按顺序显示每一行。
<div class="row" >
<my-rows
*ngFor="let row of rows | keys; trackBy: trackByFn; let index = index"
[month]='row.value'
[title]='row.key'>
</my-rows>
</div>
getRerports(url: string, dates: any, id: any){
let params = new URLSearchParams()
params.set('company_id',id)
params.set('date',dates[0])
this.authHttp.get(this._getReportsUrl,{search:params})
.subscribe(
data=>{
let formatedDate = moment(data.json().date,'YYYY-MM-DD').format('MMMM YYYY')
this.rows[formatedDate] = data.json()
dates.splice(0,1)
this.flag = false
if(dates.length>0){
this.getRerports(this._getReportsUrl,dates, id)
}else{
this.flag=true
}
},
err=> console.log(err)
)
}
trackByFn(index:any, item:any) {
return index;
}