【发布时间】:2015-02-12 16:36:14
【问题描述】:
按照本教程:http://www.w3schools.com/angular/angular_http.asp 我可以完美解析 json,但我遇到了问题。我有一个带有 json 的 php,其中有一个类似这样的 json:
{"item":[
{
"Name" : "Alfreds Futterkiste",
"City" : "Berlin",
"Country" : "Germany"
},
{
"Name" : "Berglunds snabbköp",
"City" : "Luleå",
"Country" : "Sweden"
}]}
如您所见,有一个 JSONObject (item).. 实际上要解析没有 JSONObject 的 json,我在控制器中执行此功能:
$http.get(JSONUrl)
.success(function(response) {
$scope.names = response;
});
然后
<div data-ng-controller="MainController">
<table class="uk-table uk-table-striped uk-table-hover" data-ng-if="!loading && !error">
<thead>
<th>Nome</th>
<th>Ver</th>
<th>Code</th>
</thead>
<tbody>
<tr data-ng-repeat="item in names">
<td>{{item.Name}}</td>
<td>{{item.City}}</td>
<td>{{item.Country}}</td>
</tr>
</tbody>
</table>
</div>
但在我的情况下,我没有显示任何内容,因为我将“项目”作为 JSONObject.. 任何解决方案?
【问题讨论】:
标签: javascript php json angularjs