angularjs - multiple $http.get not working -


having issues bringing in multiple data api endpoints. results come undefined values in $q.all method

$http.get('url').success(function(data, status, headers, config) {         $scope.data1= data;     })     $http.get('url').success(function(data, status, headers, config) {         $scope.data2= data;     })     $http.get('url').success(function(data, status, headers, config) {         $scope.data3= data;     })     $http.get('url').success(function(data, status, headers, config) {         $scope.data4= data;     })        $q.all([$scope.data1, $scope.data2, $scope.data3, $scope.data4]).then(function(values) {         $scope.data= values;     }); 

$q.all takes array of promises you'd have this.

$scope.promise1 = $http.get('url'); $scope.promise2 = $http.get('url'); $scope.promise3 = $http.get('url'); $scope.promise4 = $http.get('url');  $q.all([$scope.promise1, $scope.promise2, $scope.promise3, $scope.promise4]).then(function (values) {     $scope.data = values; }); 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -