我對此有點困惑。我在函數中有兩個get調用。一旦這個完整的功能,那就是兩個get調用完成了,只有這個功能完成了它的工作。我應該如何使用$ q來讓它按照我的需要工作?這是我現在有:
function updateBlackList() {
$http.get("http://127.0.0.1:8000/blacklist/entries/vehicle").then(function (res){
console.log(res)
}).catch(function (err) {
console.log(err)
});
})
$http.get("http://127.0.0.1:8000/blacklist/entries/person").then(function (res){
console.log(res)
}).catch(function (err) {
console.log(err)
});
});
return $q.when();
}
這裏withint另一個函數我需要等待上述fiunction完成:
BlackListService.updateBlackList().then(function() {
addVersion(server_version).then(function() {
console.log("Blacklist update complete")
})
})
它沒有這樣做就像我懷疑它做的事。在TW GET請求完成
這很酷,謝謝你!我會記住 – Harry