0

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:

enter image description here

Thanks, J

1
  • 1
    Show us your HTML and how do you know $scope.exportData is blank? Are you using batarang or ng-inspector? I'm guessing that you're setting $scope.exportData to your 5 item array. You're probably not implementing it right in the HTML. Commented Jun 12, 2014 at 20:18

2 Answers 2

2

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;
});
Sign up to request clarification or add additional context in comments.

Comments

1

missing semi-colon after result.data

can also try

angular.forEach(result.data, function(item) {
  // set a break point here:
  $scope.exportData.push(item);
});

2 Comments

$scope.exportData still appears blank at the end and I did some debugging, nothing is coming up for item
each array is an oject

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.