I have a list that looks like this:
$http methods return a promise, which can't be iterated, so you have to attach the results to the scope variable through the callbacks:
$scope.documents = [];
$http.get('/Documents/DocumentsList/' + caseId)
.then(function(result) {
$scope.documents = result.data;
});
Now, since this defines the documents variable only after the results are fetched, you need to initialise the documents variable on scope beforehand: $scope.documents = []. Otherwise, your ng-repeat will choke.
This way, ng-repeat will first return an empty list, because documents array is empty at first, but as soon as results are received, ng-repeat will run again because the `documents``have changed in the success callback.
Also, you might want to alter you ng-repeat expression to:
-
because if your DisplayDocuments() function is making a call to the server, than this call will be executed many times over, due to the $digest cycles.