【发布时间】:2016-05-27 10:16:05
【问题描述】:
我的 json 看起来像这样:
[
{
"statCount": 5,
"inceptionStat": [
{
"1": "name1",
"2": "name2",
"3": "name3",
"4": "name4",
"5": "name5"
}
]
},
{"statCount": 2,
"inceptionStat":
[
{
"1": "name1",
"2": "name2"
}
]
},
{
"statCount": 0,
"inceptionStat": [
{}
]
}
]
我想在 angularjs 中使用 inceptionStat 数组来创建我所有名字的列表,我尝试了多种方法,但我没有找到一种方法只为每个 statCount 打印 name1、name2 等。
我使用了一些 javascript 来隔离 inceptionStat 数据:
$scope.result = $($scope.data).map(function () {
return this.inceptionStat;
}).get()
console.log($scope.result);
$scope.data 这里是整个 json 数据。
所以从这里开始,我尝试使用 ng-repeat 从我的不同数组对象创建我的名称列表,但我没有找到我猜的正确方法。
有没有简单的方法来做到这一点?
【问题讨论】:
-
你能告诉我如何你尝试使用
ng-repeat吗?
标签: javascript angularjs json dictionary