Javascript 顺序需要执行角度代码

Javascript 顺序需要执行角度代码,javascript,angular,typescript,angular-promise,Javascript,Angular,Typescript,Angular Promise,我想按顺序执行代码,首先需要执行foreach循环,然后调用getHistory()方法。提前谢谢 const start = async()=>{ await this.currentContent.forEach(async currentContent => { if (!currentContent.footnote) { let tempContent: any = await this._http.ge

我想按顺序执行代码,首先需要执行foreach循环,然后调用getHistory()方法。提前谢谢

const start = async()=>{


         await this.currentContent.forEach(async currentContent => {
          if (!currentContent.footnote) {


            let tempContent: any = await this._http.get(`VersionHistory/ContentAuditTrail/${currentContent.id}/${this.newDatetimeSelection}`).toPromise();
            if (tempContent){
              console.info('end time call : raw content');
              currentContent.rawContent = tempContent.value;

            }
            // content.rawContent = await this._http.get(`VersionHistory/ContentAuditTrail/${c.id}/${this.oldDatetimeSelection}`).toPromise();
          } else {

            let newcontent: any = await this._http.get(`VersionHistory/ContentFootnoteAuditTrail/${currentContent.footnote.id}/${this.newDatetimeSelection}`).toPromise();
            if (newcontent) {
              console.info('end time call : footnote content');
              currentContent.footnote.footnote = newcontent.value;

            }
          }
        })
        //setTimeout(() => {
          console.info('end time call');
          this.getHistory();
        //}, 4000);
      }

      start();
像这样的-

Promise.all(this.currentContent.map(##first part of your code##))
    .then(() => {
        console.info('end time call');
        this.getHistory();
})

您正在为
forEach
提供一个异步函数。因此,即使您说
等待someArray.forEach
,它也不会等待所有异步回调。@VLAZ我对javascript和typescript不熟悉。你能帮我查一下这个密码吗?