Reputation: 137
I am having a problem displaying a JSON response on web page using Angularjs, on DevTools i can see that the GET request work great and can grab all data, but when it comes to dislaying it on a list all i got is dots .
My controller :
budgetApp.controller('DepensesListCtrl', ['$scope', '$http',
function DepensesListCtrl($scope, $http) {
$scope.depenses = [];
$http.get('http://localhost:3000/api/depenses', {withCredentials: true}).success(function(data) {
$scope.depenses = data;
});
Using ng-repeat :
<div >
<div class="jumbotron text-center">
<h1>depenses Page</h1>
</div>
<ul ng-repeat="depense in depenses">
<li>{{depense.depname}}</li>
<li>{{depense.depcat}} </li>
</ul>
I tried debuging with alerts, i figured out that my depenses array allways give undefined
Upvotes: 0
Views: 50
Reputation: 171679
Your data is an object that has a property Depense
that contains the array you want to repeat
Try:
$http.get('http://localhost:3000/api/depenses', {withCredentials: true}).success(function(data) {
$scope.depenses = data.Depense;
// ^^^ property that contains array
});
OR:
<ul ng-repeat="depense in depenses.Depense">
Upvotes: 1