问题描述
我正在尝试进行大规模删除,以使我拥有要删除的ID的 Array< number>
.我无法将此数组作为参数传递给方法 this._httpService.delete(uri,options)
. _httpService
的类型为 Http
.
I'm trying to make a massive delete, in order to do that I have an Array<number>
of the ids I want to delete. I can't pass this array as a parameter to the method this._httpService.delete(uri,options)
. The type of _httpService
is Http
.
因此,我正在循环数组并在循环内进行单个调用,但是每个调用都是异步的,并且在循环结束时我有一定的逻辑可以运行.
So I'm looping the array and inside the loop I'm making single calls, but each call is async and I have certain logic to run when the loop ends.
推荐答案
实际上,根据,例如:
http.delete('/api/something', new RequestOptions({
headers: headers,
body: anyObject // this would contain your ids
}))
因此,您的应用程序不发出数百个请求,而仅发出一个带有所有ID的请求.
So instead of issuing hundreds of requests, have your app make just one with all ids in the body.
这篇关于如何使用ID数组在Angular 4中进行大规模删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!