Ng-重复数组到行和列 [英] Ng-Repeat array to rows and columns
本文介绍了Ng-重复数组到行和列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
感谢您抽出宝贵的时间阅读本文,我想知道如何使用ng-repeat创建类似选项框的网格.我想让一个数组重复第n个项目,然后移到下一行或下一行,直到列出所有项目.例如
Thanks for taking the time to read this, I was wondering how I might be able to use ng-repeat to create a grid like box of options. I would like to take an array repeat nth number of items and then move to the next row or column until all items are listed. e.g.
假设我有一个像[opt1,opt2,opt3,opt4,opt5,opt6,opt7]
这样的数组,我想这样显示它:
assuming I had an array like [opt1,opt2,opt3,opt4,opt5,opt6,opt7]
I would like to display it like this:
opt1 opt2 opt3
opt4 opt5 opt6
opt7
推荐答案
与AngularJS相比,这更多是样式/标记问题.如果您确实愿意,可以执行以下操作:
This is more a styling/markup problem than an AngularJS one. If you really want to, you can do:
<span ng:repeat="(index, value) in array">
{{value}}<br ng:show="(index+1)%3==0" />
</span>
这篇关于Ng-重复数组到行和列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文