如何使用 ng-repeat 显示数组/对象

詹姆斯开发者

我有一个如下所示的数组:

数组格式

我想使用 angularJS ng-repeat 显示它,同时显示每个的计数和值。

这是目前我拥有的 HTML 和 angular,但没有显示任何内容。

我也不需要在数组中显示 0 索引,如果可能的话,我想从 1 开始。

 <tr ng-class="" ng-repeat="x in vm.data | filter: searchArray">
       <td>{{x.value}}</td>
       <td>{{x.count}}</td>
 </tr>

在此处输入图片说明

詹姆斯开发者

我回到了基础,明白 ng-repeat 只是 javascript 中的一个循环,如果你的数组是多维的,如果你想在 JavaScript 中访问数据,你需要做什么?好吧,你做了一个嵌套的 for 循环,这正是我在这种情况下所做的。

这是显示我需要的数据的更新后的 html/angularjs:

<tbody>
    <tr ng-repeat="x in vm.data">
        <td ng-repeat="y in x">{{y.value}}  {{y.count}}</td>
    </tr>
</tbody>

再次感谢各位!

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何替换使用ng-repeat显示的数组中的对象?

如何使用ng-repeat显示数组中对象的特定属性

使用ng-repeat遍历对象数组

需要在使用 ng-repeat 时在对象内的数组中显示对象

如何使用ng-repeat显示嵌套对象

如何在多个对象数组上使用ng-repeat?

如何使用ng-repeat遍历对象内的数组

如何使用 ng-repeat 在表格中显示数组

使用 ng-repeat 不显示列表对象

使用Angular ng-repeat遍历对象数组的非均匀

在对象的嵌套数组上使用ng-repeat

ng-repeat显示html数组中对象的索引

AngularJS:如何使用ng-repeat显示父数组中包含的数组的所有元素

如何使用ng-repeat遍历JSON中的数组数组?

如何从ng-repeat获取数组项?

在 json 对象上使用 ng-repeat

如何使用 forEach 从 ng-repeat 中删除 json 对象

使用ng-repeat如何从嵌套的JSON对象检索数据

当使用ng-repeat时,如何仅显示更改的字段?

AngularJS:如何在 HTML 中使用两个 ng-repeat 显示深度对象值

如何在Ionic框架中使用ng-repeat显示嵌套的JSON对象?

AngularJS-ng-repeat-如何使用ID创建数组

如何使用 ng-repeat 迭代存储在对象中的数组

如何使用AngularJS从ng-repeat中的数组中删除对象?

如何在包含其他值的对象的数组上使用ng-repeat

如何在离子中使用ng-repeat显示数组值

使用ng-repeat显示对象的子数组列表,其中每个数组包含重复项,每个索引包含1个项目符号

ng-repeat与数组

您如何ng-repeat通过对象的对象来显示键和值?