小编use*_*577的帖子

多个httpclient post调用进入foreach循环angular 5

我需要使用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)

post call httpclient rxjs angular

0
推荐指数
1
解决办法
2817
查看次数

标签 统计

angular ×1

call ×1

httpclient ×1

post ×1

rxjs ×1