Mike
Mike

Reputation: 3418

AngularJS Service fetches Json but wont show it in browser or in an ng-repeat

I have been struggled with this for quite sometime, though I am fairly new to angularjs but I cant figure out whats going on wrong here, coz console logs nothing as error.

I have reproduced the issue at a plunk. What I want is the value and Reps logged. Everything seems to be okay but I have a feeling that I am not Binding Services and Controllers properly(Maybe)

Any help is hugely appreciated..

http://plnkr.co/edit/Kqvm2bTNNm0wfAXMpcKg

Upvotes: 0

Views: 53

Answers (1)

thescientist
thescientist

Reputation: 2948

$http returns a promise, use then() to set the items using the items property of your response.

testAPP.controller('stackCtrl', function stackCtrl($scope, userQuestionService) { $scope.name = "This is a Heading"; userQuestionService.getUserQuestions().then(function(response){ $scope.items = response.items; }); });

I had this as the test output

Reps is {{item.a_id}} and Value is {{item.owner.reputation}}

Upvotes: 3

Related Questions