Reputation: 393
I am using this $http.get call in my angular JS:
$scope.exportData = [];
$http.get('/reports?UserId=1').then(function (result) {
$scope.exportData = result.data
});
$scope.exportData
returns blank :(
but when I debug this I see that result.data
is getting populated and result.data
has 5 arrays in it...my question is how would I put each of those arrays in $scope.exportData
result.data
has a length value of 5. Maybe I could use that to do a foreach? I would know how to do that in php by javascript/jquery/angular js I am a newbie. Any help would be much appreciated.
Here is a screenshot on what gets populated for results.data:
Thanks, J
Upvotes: 0
Views: 2326
Reputation: 2547
missing semi-colon after result.data
can also try
angular.forEach(result.data, function(item) {
// set a break point here:
$scope.exportData.push(item);
});
Upvotes: 1
Reputation: 191
Perhaps the nested function is not getting called. $http.get([url]) is a valid shortcut and thus may be populating result.data, however you do not specify the success or failure call backs.
Perhaps try:
$http.get('/reports?UserId=1').success(function (result) {
$scope.exportData = result;
});
Upvotes: 2