0
有沒有辦法多次撥打服務?我想從我的數據庫加載一些數據和情況的一個長長的清單,我想在每個請求裝載1000個條目,如果我這樣做:Angular2 - 多次撥打服務
而(!做){...}
我會得到許多不需要的數據庫請求,但我可以得到我所有的數據。
這是我在component.ts
lazyLoadData(): void {
this.getUntil += 1000;
if (this.getUntil > this.totalEntries) {
this.getUntil = this.totalEntries;
}
this.salesService.GetEDISalesReportDetailListLazy(this.id, this.getFrom, this.getUntil)
.then(data => {
if(this.dataTable == null) {
this.dataTable = [];
this.dataTable = data;
this.isDataTableAvailable = true;
this.status = this.dataTable.aaData[0].Status;
} else {
for(let i = 0; i< data.aaData.length; i++){
this.dataTable.aaData.push(data.aaData[i]);
}
this.getFrom = this.getUntil;
}
});
}
方法,這是我service.ts
GetEDISalesReportDetailListLazy(id: number, startFrom: number, until: number): any {
return this.http2.post(SERVICE_URL + 'Sales/GetEDISalesReportDetailListLazy', { id: id, startFrom: startFrom, until: until }, this.options)
.toPromise()
.then(response => {
return response.json().ReturnStatus.ReturnObject;
})
.catch(this.handleError);
}
任何意見,我該怎麼辦呢? 非常感謝您的幫助。
要調用這個服務1000次?我可以知道爲什麼 –
不,這就是我每次會得到多少條目 –
你需要打多少次服務請你澄清一下這個問題 –