try this:
function checkInventoryUrl(url, size, code) {
var inventoryData = {};
return $http.get(url).then(function (response) {
var html = response.data;
// returns value instantly
inventoryData.url = url;
// parses html, takes a few seconds to return value
inventoryData.name = getProductName(html);
inventoryData.price = getPrice(html);
// returns promise
return $q.all([
getProductQty(html, size).then(function (result) {
if (result) {
inventoryData.qtyAvailable = result;
console.log(inventoryData);
}
}),
getProductMaxOrder(html, size).then(function (result) {
if (result) {
inventoryData.maxOrder = result;
console.log(inventoryData);
}
}),
getProductSize(html, size).then(function (result) {
if (result) {
inventoryData.size = result;
console.log(inventoryData);
}
})
])
.then(function dumm() {
return inventoryData;
})
});
}
You are returning your result (inventoryData) before your promises are
done.
Regards
Sander
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.