【发布时间】:2016-02-17 08:27:34
【问题描述】:
亲爱的,
如何在 nodejs 中按顺序运行 Promise,在下面的示例中,我循环遍历小时数组,然后对于每个获取的小时从数据库中获取结果,这里的问题:正在获取结果,但我希望它按顺序与我得到的顺序相同小时 。
angular.forEach(SharedVar.getCategories(), function (h) {
t = h.split('-', 2);
t = t[0];
RESTApi.getAnswerdCallsByHour(t).then(function (answerdTotal) {
$scope.answerdCallsTotalByHour.push(answerdTotal);
var d = SharedVar.getDataS();
d[count] = answerdTotal;
SharedVar.setDataS(d);
count++;
});
});
谢谢,
【问题讨论】: