“{\”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 \”:\ “苏雷什\”,\ “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 \”:\ “苏雷什\”,\ “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>
答案 0 :(得分:1)
您需要解析响应,因为它是字符串。
$http.get("clients.php").then(function (response) {
$scope.response = response;
$scope.results = JSON.parse(response.data);//Parsing string to JSON
console.log($scope.results);
}
<table>
<tr ng-repeat="result in results.user_transaactions">
<td>{{ res.beneficiary_first_name}}</td>//No need of using index of array
<td>{{ res.transaction_status }}</td>
</tr>
</table>
答案 1 :(得分:1)
首先,您必须使用JSON.parse()
将字符串结果解析为JSON。
$scope.results = JSON.parse(response.data);
你的html中还有另一个问题
<table>
<tr ng-repeat="result in results.user_transactions">
<td>{{ result.beneficiary_first_name}}</td>
<td>{{ result.transaction_status }}</td>
</tr>
</table>
<强> Working Demo 强>