【发布时间】:2020-06-22 07:00:26
【问题描述】:
我有一个当前使用 Angular 1.7 的应用程序,我们有一个 IHTTPPromise (updateCase),然后我们在解决 then() 方法后处理代码
在第一个 then() 之前,我想链接另一个 then() 以设置 x 毫秒的等待时间
我不能只使用setTimeout(),因为它不会返回 Promise。
在 Angular 1.7 中,如何创建一个新的 Promise 来包含 setTimeout 然后解析并允许我链接 then 语句?
this.caseService.updateCase(updateCaseRequest)
//***WANT TO ADD A WAIT HERE
.then(
response => {
this.showUpdateComplete();
this.getCases();
this.$scope.selectedCase = selectedCase;
})
}
【问题讨论】:
-
使用 Promise 构造函数?
-
这能回答你的问题吗? How do you wrap setTimeout in a promise
标签: angularjs typescript promise ecmascript-5