This particular post is building upon a previously solved issue. For more context, please refer to the following link: Nesting promises with $resources in AngularJS 1.0.7
Based on the approach outlined in the previous post, my goal is to simultaneously call two functions and then execute the searchBoats function once both are completed. I believe this can be achieved by either nesting promises or using $q.all for parallel execution. However, I find the topic of promises confusing and require guidance on how to proceed.
In reference to the example provided in the earlier post, my objective is to achieve something like the following:
var parseURL = function() {
var deferred = $q.defer();
var promise = deferred.promise;
promise.then(function success(result) {
console.log(result);
searchBoats(result);
});
// Instead of resolving when the parseBoatType promise is returned, I aim to
// await the completion of two promises
parseBoatType().then(deferred.resolve);
parseDestination().then(deferred.resolve);
// It should be noted that the current implementation resolves deferred upon
// the arrival of the first promise. Can $q.all be utilized here?
};
parseURL();