Angularjs HTTP响应问题
我已经使用restapi从服务器获取响应。当我在客户端打电话时,我正在获取所需的响应对象,但数据没有显示出来。请告诉我哪里出了问题Angularjs HTTP响应问题,angularjs,Angularjs,我已经使用restapi从服务器获取响应。当我在客户端打电话时,我正在获取所需的响应对象,但数据没有显示出来。请告诉我哪里出了问题 app.controller('Ctrl',['$scope','$http', function($scope,$http) { $http({ url: '//localhost:800/psp/policies', method: 'GET', }).then( fu
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>
Sl。
保单名称
发行日期
描述
看法
过程
{{bank.id}
{{bank.policy_name}
{{银行发行日期}
{{bank.description}}
{{bank.view}
{{bank.process}
查看响应后,看起来是这样的:响应是
对象
,其中包含银行政策
作为数组
作为属性
<tr ng-repeat="bank in bankpolicy.bankpolicy">
//code
</tr>
//代码
successCallbackresponse对象中console.log($scope)的功能@先生,你确定吗$scope应该为您提供当前范围的范围对象。你能举个例子吗?试试我在mys答案中更新的内容。还要检查console.log(response.data.bankpolicy);看起来像是data
实际上持有bankpolicy
本身$scope.bankpolicy=response.data.bankpolicy
会起作用……是的。这是一个数组。OP最初添加了注释,表示它是对象。