【发布时间】:2015-03-10 00:48:46
【问题描述】:
我是 Angular JS 的新手,我想在 ng-repeat 中显示一个 php 数组。 这是我的html代码,
<div ng-controller="clientList">
<ul>
<li ng-repeat="client in clients">
<h2>{{client.job}}</h2>
</li>
</ul>
<p>Total number of phones: {{clients.length}}</p>
</div>
这是我的 Angular JS 控制器,
var anguApp = angular.module('anguApp', []);
anguApp.controller('clientList',function($scope,$http)
{
$scope.clients=[];
$http.get('customers.php').success(function (data, status) {
$scope.clients = data;
console.log(data);
});
});
customers.php
<?php
$arr=['name'=>'David','job'=>'developer'];
header('Content-Type: application/json');
echo json_encode($arr);
?>
控制台日志: 在控制台中得到很好的响应。但没有进入浏览器。错误在哪里?....
【问题讨论】:
-
你能在这里附上你的console.log(data)结果吗?
标签: javascript php html json angularjs