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