Skip to content

Instantly share code, notes, and snippets.

@zivester
Last active December 14, 2015 17:28
Show Gist options
  • Select an option

  • Save zivester/5122216 to your computer and use it in GitHub Desktop.

Select an option

Save zivester/5122216 to your computer and use it in GitHub Desktop.
angular.js: $q parallel set
var fields = {};
var p1 = $http.get('/api/field/sizes').success(function(sizes){
fields.sizes = sizes;
});
var p2 = $http.get('/api/field/colors').success(function(colors){
fields.colors = colors;
});
$q.all(p1, p2).then(function(){
// How do I have 'fields' populated here?
console.log(JSON.stringify(fields)); // returns '{}'
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment