Angular Http按序列发布

时间:2019-04-26 14:10:56

标签: angular typescript

每次发布​​时都会有这种数据。它在数据库中随机发布如何按顺序发布。要先保存12> 13> 14> 3

let regularBudgetStatus = [
{logicalFrameworkId,logFrameActionStatusReferenceId : 12,remarks : 'ACCEPTED->INCLUSION', actedByEIC },
{logicalFrameworkId,logFrameActionStatusReferenceId : 13,remarks : 'ACCEPTED->APPROPRIATION',actedByEIC },
{logicalFrameworkId,logFrameActionStatusReferenceId : 14, remarks : 'ACCEPTED->RECOMMENDATION', actedByEIC },
{logicalFrameworkId,logFrameActionStatusReferenceId : 3,remarks : 'ACCEPTED->AIP 1ST DRAFT', actedByEIC}
];


this.programservice.saveStatus(item)
.toPromise()
.then(
res => {console.log("success")})
.catch(() => console.log("error"));
});

1 个答案:

答案 0 :(得分:0)

您可以传递整个数组,然后按顺序从后端应用程序中保存它们。 但是,如果不能这样做,请尝试以下操作:

=INDEX(IMPORTXML("https://sg.finance.yahoo.com/quote/AMZN","//td[@data-test='AVERAGE_VOLUME_3MONTH-value']/span"),1)

然后只需调用saveNextItem(i: number) { this.programservice.saveStatus(item) .toPromise() .then( res => { console.log("success") if(i < regularBudgetStatus.length-1) this.saveNextItem(i++); }) .catch(() => console.log("error")); } 即可依次保存整个数组。使用regularBudgetStatus [i] .logFrameActionStatusReferenceId更改“ item”变量,为简单起见,我没有更改它。