我如何制作storyboard.getAdressTimeLine同步,我想要storyboard.drawTimeLine执行,直到storyboard.getAdressTimeLine完成
for (var i = 0; i < response.data.length; i++) {
var obj=response.data[i];
var date = obj.fixtime.substring(0, 11);
storyboard.getAdressTimeLine(obj.latitude,obj.longitude);
storyboard.drawTimeLine(date + "00:00:00.000+0000", obj.fixtime, "red",0,storyboard.lastAdressTime);
items.push(item);
}
答案 0 :(得分:0)
在这里使用promises这个angularjs文档将帮助你https://docs.angularjs.org/api/ng/service/ $ q
如果您使用承诺,您的功能将如下所示
storyboard.getAdressTimeLine(obj.latitude,obj.longitude).then(function(){
storyboard.drawTimeLine(date + "00:00:00.000+0000", obj.fixtime, "red",0,storyboard.lastAdressTime);
})