Skip to content

Instantly share code, notes, and snippets.

@coolicer
Created September 2, 2014 09:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coolicer/6366b8f97a5507ea9aa9 to your computer and use it in GitHub Desktop.
Save coolicer/6366b8f97a5507ea9aa9 to your computer and use it in GitHub Desktop.
angular-promise-all
var one = $q.defer();
var two = $q.defer();
var getInStock =function(){
var params = {
proc: 'getStockCount',
param: {
type:0,
manufacturer: $scope.query.manufacturer || '',
begin: $scope.beginDay || '',
end: $scope.endDay || ''
}
};
Query.go('/data/get', params).then(function(result){
one.resolve(result.data.list0)
})
return one.promise;
}
var getOutStock = function () {
var params = {
proc: 'getStockCount',
param: {
type:1,
manufacturer: $scope.query.manufacturer || '',
begin: $scope.beginDay || '',
end: $scope.endDay || ''
}
};
Query.go('/data/get', params).then(function(result){
two.resolve(result.data.list0)
})
return two.promise;
};
$q.all([getInStock(),getOutStock()]).then(function(value){
console.log(value)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment