javascript - how to access array data from api in angularjs -


i want access array calling api in angular js. , use them in ng-repeat

angularcode:

$scope.onsubmit = function () {     $scope.records = [];     var answers = [];     // post data server here. answers contains questionid , 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 api in ng-click event ,i receiving data api cannot use them in ng-repeat records not displaying in html instead showing error:

 angular.js:12477 referenceerror: records not defined 

how solve problem ??

you have:

$scope.records = data; console.log(records); 

obviously second line must be:

console.log($scope.records); 

as records (just "records") not defined outside of scope.


Comments

Popular posts from this blog

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -