这是我的代码
if($_SERVER["REQUEST_METHOD"] == "POST")
{
$customer_array = array();
$customer1 = array(
'customer_id' => '1',
'name' => 'Larry',
'city' => 'Houston'
);
$customer_array[] = $customer1;
$customer2 = array(
'customer_id' => '2',
'name' => 'tom',
'city' => 'Hoff'
);
$customer_array[] = $customer2;
echo json_encode($customer_array);
}
这是Angular部分
var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http) {
$http.post("customers.php").then(function (response) {
$scope.myData = response.data
});
});
如何修改我的控制器以同时提取customer1和customer2数组,或者同时提取customer1和customer2?所以,简而言之,两个阵列或只有一个。