【发布时间】:2017-07-27 10:49:58
【问题描述】:
"{\"success\":true,\"message\":\"找到交易历史记录。\",\"user_transactions\":[{\"user_id\":\"4\",\" amount_charged\":\"4.00\",\"amount_transferred\":\"14400.00\",\"app_rate\":\"3600.00\",\"charged_currency\":\"USD\",\"beneficiary_phone\ ":\"256775542757\",\"beneficiary_first_name\":\"Sapkota\",\"beneficiary_last_name\":\"Suresh\",\"beneficiary_country\":\"UG\",\"transferred_currency\": \"UGX\",\"transaction_status\":\"Delivered\",\"order_id\":\"259\",\"created_date\":\"2017-07-25 13:35:48\" ,\"last_modified_date\":\"2017-07-25 13:35:48\"},{\"user_id\":\"4\",\"amount_charged\":\"5.00\",\" amount_transferred\":\"18000.00\",\"app_rate\":\"3600.00\",\"charged_currency\":\"USD\",\"beneficiary_phone\":\"256775542757\",\"beneficiary_first_name\ ":\"Sapkota\",\"beneficiary_last_name\":\"Suresh\",\"beneficiary_country\":\"UG\",\"transferred_currency\":\"UGX\",\"transaction_status\": \"Delivered\",\"order_id\":\"258\",\"created_date\":\"2017-07-25 06:23:05\",\"last_modified_date\":\"2017-07 -2 5 06:23:05\"}]}"
使用 Get 获取的内容如下:
$http.get("clients.php").then(function (response) {
$scope.response = response;
$scope.results = JSON.parse(response.data);
console.log($scope.results);
}
问题是,在控制台.log 中没有得到任何结果,而在我以这种方式编写的表行中没有任何结果。所以,请任何人帮助我。
<table>
<tr ng-repeat="result in results.user_transactions">
<td>{{ result.beneficiary_first_name}}</td>
<td>{{ result.transaction_status }}</td>
</tr>
</table>
【问题讨论】:
-
您的数据是字符串。首先使用 JSON.parse() 解析它
-
你为什么不安慰响应?先检查一下。
-
在控制台响应时,我得到: Object {data: ""{\"success\":true,\"message\":\"Transaction histo..."last_modified_date\":\"2016 -11-01 16:55:31\"}]}"",状态:200,配置:对象,状态文本:“确定”,标题:函数}
-
@SureshSapkota $scope.results = JSON.parse(response.data) 的控制台是什么
-
我能够解析您的数据。不知道为什么它在那里不起作用。您是否缺少要在此处添加的内容?