I want to access an array by calling API in angular js. and use them in ng-repeat
angularcode:
$scope.onsubmit = function () {
$scope.records = [];
var answers = [];
// Post your data to the server here. answers contains the questionId and the users' answer.
$http.get('http://localhost/api/leaderboard/:quizId', answers).success(function successCallbac(data,status) {
$scope.records = data;
//console.log(records);
});
};
Html code:
<div ng-repeat="list in records">
<div class="row">
<h3>{{list}}}</h3>
<h3> {{ list}}</h3>
</div>
</div>
I called an API in ng-click event ,I am receiving data from API but i cannot use them in ng-repeat records are not displaying in html instead it is showing the error:
angular.js:12477 ReferenceError: records is not defined
how to solve this problem ??