【发布时间】:2013-11-25 08:36:43
【问题描述】:
我有一个 $http 调用,我用它检索对象数组。我对该端点进行了三次调用,最终得到三个数组,如下所示:
[
{type: Dog, count: 3}
{type: Cat, count: 4}
{type: Elephant, count: 1}
]
[
{type: Dog, count: 1}
{type: Cat, count: 9}
]
[
{type: Dog, count: 19}
{type: Cat, count: 4}
{type: Elephant, count: 12}
{type: Frog, count: 2}
]
第一次调用是 8 月的统计数据,9 月 2 日,10 月 3 日。
然后我想要创建一个看起来像这样的数据集......
[
{type:Dog, data:[3,1,9]}
{type:Cat, data:[4,9,4]}
{type:Elephant, data:[1. null, 12]}
{type:Frog, data:[null, null, 2}
]
... 这样我就可以使用 ngRepeat 遍历每个元素以显示月份/动物统计数据表。
有人有什么想法吗?
谢谢。
【问题讨论】:
标签: arrays angularjs loops object angularjs-ng-repeat