我需要使用httpclient进入foreach循环。有可能的?正确的方法是什么?这是我的代码:
this.attachToDelete.forEach(
element => {
this.documentService.DeleteAttachment(element, this.newDocumentId.toString());
console.log("upload delete from submit", element);
}
);
Run Code Online (Sandbox Code Playgroud)
这是对应服务中的方法:
public DeleteAttachment(attachmentId: number, documentId: string) {
let headers = new HttpHeaders();
headers = headers.set('Content-Type', 'application/json; charset=utf-8');
return this.http.post('http://localhost:8080/DocumentAPI/api/document/RemoveAttachment?docId=' + documentId + '&attachmentId='+attachmentId, attachmentId, { headers: headers }).subscribe(
data => {
if(data)
console.log("delete attach????", data);
else{
console.log('Error occured');
}
}
);
}
Run Code Online (Sandbox Code Playgroud)