【发布时间】:2014-05-15 14:12:23
【问题描述】:
我不确定如何在 AngularJS 的帮助下遍历这个 JSON 数据
{
{
"1590": {
"id": "1590",
"id_site": "0",
"id_merk": "7",
"id_type": "209",
"uitvoering": "Blue Lease Execut. HYbrid4 2.0 HDi 4D 147kW"
},
{
"1590": {
"id": "1590",
"id_site": "0",
"id_merk": "7",
"id_type": "209",
"uitvoering": "Blue Lease Execut. HYbrid4 2.0 HDi 4D 147kW"
}
}
这就是我现在的 Angular 应用程序中的内容:
服务:
(function () {
var releasingService = function ($http) {
var brands = [];
$http.get('/releasing.json')
.then(function(results) {
brands = results;
});
this.getBrands = function () {
return brands;
};
};
releasingService.$inject = ['$http'];
angular.module('releasingApp').service('releasingService', releasingService);
}());
查看
<select data-ng-model="brands" data-ng-options="brand.Id for brand in brands">
<option value="">-- Selecteer een merk --</option>
</select>
当前视图未显示任何结果。我不知道如何处理数组中的不同对象。
任何帮助将不胜感激。
【问题讨论】:
-
用 { { } } 看起来不像是一个有效的 json,你写的 json 是什么样子的吗?
-
是的,这实际上是我从服务器请求 JSON 时的样子。所以我不能自己改变输出。
标签: json angularjs angularjs-ng-repeat arrays