【发布时间】:2019-03-19 04:35:33
【问题描述】:
我将如何在 Angular 6 中使用 rxjs 来插入项目,然后在插入后我需要将不同类型的文件上传到不同的端点,并将新的项目 ID 作为子键,而不必嵌套所有这些调用。
createItemWithAttachments(data:any)
{
this.itemService.insert(data.item).subscribe((newItem:Item)=>{
//attachment type 1s
if(data.attachmentType1.length > 0){
this.attachmentService.upload(data.attachmentType1,
"type1", newItem.id).subscribe(newAttachment=>{
});
}
//attachment type 2s
if(data.attachmentType2.length > 0){
this.attachmentService.upload(data.attachmentType2,
"type2", newItem.id).subscribe(newAttachment=>{
});
}
});
}
【问题讨论】: