Reputation: 231
I have used restapi to fetch the response from the server. When I make a call on the client side I am the getting the required reponse object, but the data is not getting displayed. Please let me know where I am going wrong.
app.controller('Ctrl',['$scope','$http', function($scope,$http) {
$http({
url: '//localhost:800/psp/policies',
method: 'GET',
}).then(
function successCallback(response) {
$scope.bankpolicy = response.data;
console.log(response.data);
},
function errorCallback(response) {
console.log("Error:" + response.data)
})
}]);
HTML :
<div class="col-md-8 txt" ng-controller="Ctrl">
<table class="table-write">
<thead class="rowhead">
<tr>
<th class="mid">Sl.</th>
<th id="tnm">PolicyName</th>
<th class="mid">date_of_issue</th>
<th class="mid">description</th>
<th class="mid">View</th>
<th class="mid">Process</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="bank in bankpolicy">
<td>{{bank.id}}</td>
<td>{{bank.policy_name}}</td>
<td>{{bank.date_of_issue}}</td>
<td>{{bank.description}}</td>
<td>{{bank.view}}</td>
<td>{{bank.process}}</td>
</tr>
</tbody>
</table>
Upvotes: 2
Views: 71
Reputation: 12093
After looking to response it looks like this the response is Object
that contains bankpolicy
as array
inside it as property.
<tr ng-repeat="bank in bankpolicy.bankpolicy">
//code
</tr>
Upvotes: 2