{
"data": [{ "id": 1, "name": "iPhone 5s", "amount": 10 }, { "id": 2, "name": "Nexus 5", "amount": 12 }, { "id": 3, "name": "Xperia Z1", "amount": 13 }, { "id": 4, "name": "Motorola X", "amount": 8 }, { "id": 5, "name": "Galaxy S4", "amount": 21 }],
"status": 200,
"config": {
"method": "GET",
"transformRequest": [null],
"transformResponse": [null],
"jsonpCallbackParam": "callback",
"url": "view/pagination/result.json",
"headers": { "Accept": "application/json, text/plain, */*" }
},
"statusText": "OK",
"xhrStatus": "complete"
}
如何访问数据属性。 我尝试使用ng-repeat,因为它返回正确数量的元素,但行为空
我的代码:
<table border="1" cellspacing="0">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Amount</th>
<th>Tool</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in list">
<td>{{ item.id }}</td>
<td>{{ item.name }}</td>
<td><input type="text" ng-model="item.amount"></td>
<td>
<button ng-click="doEdit(item)">Edit</button>
<button ng-click="doDelete(item)">Delete</button>
</td>
</tr>
</tbody>
</table>
在控制器中:
//ajax
$http.get('view/pagination/result.json').then(function(data) {
$scope.list = data;
});