0
我正在開始使用Angular和PHP。我有一個JSON數組,這通過0調用將PHP文件發送到AngularJS函數,但我無法在函數js中獲取JSON數組值。如何在角度js表中顯示對象數組php?
與控制檯日誌JSON結果:
PHP函數:
foreach ($result as $row) {
$out[] = $row;
}
echo json_encode($out);
JS:
app.controller('controllerJs', ['$scope', '$http', function($scope,$http){
$scope.clients = [];
$scope.All = function(){
$http.get('/App/getAll.php')
.then(function(data){
$scope.clients = data;
});
}
}]);
PHP表:
<tbody>
<tr ng-repeat="item in clients">
<td>{{item.nombre}}</td>
<td>{{item.especialidad}}</td>
</tr>
</tbody>
'$ scope.clients =數據;'==>'$ scope.clients = data.data;' –
_Small point_'的foreach ($結果爲$ row){$ out [] = $ row; } echo json_encode($ out);'___爲什麼不只是''json_encode($ result);'___並保存所有浪費的CPU週期____ – RiggsFolly