【发布时间】:2017-06-15 19:18:47
【问题描述】:
这是我的 .ts 代码
userCount(event_id){
this.http.get('http://localhost/getCount.php?event_id='+event_id)
.subscribe(res=>{
this.eventUserCount = res.json();
console.log("User NUM :: ", this.eventUserCount)
return this.eventUserCount
});
}
这是调用上述函数的 HTML 代码:
<div *ngFor="let event of events">
....
<ion-col col-6 center text-center>
<button ion-button>
<div> {{ userCount(event.event_id) }} Users</div>
</button>
</ion-col>
...
</div>
我收到来自服务器的无限响应(从 console.log 中可以看出) 我想为每个列表项发出单独的 http 请求并显示每个事件的计数,而不是这个无限的请求和响应循环。 谁能帮我解决这个问题??
【问题讨论】:
标签: javascript angular ionic-framework ionic3