通过切片与指数增量 [英] Slice by Index with increment
问题描述
我有这样的事情:
<div ng-repeat="atma in abc">
<li ng-repeat="atma in abc.slice(0,3)"><span>{{$index+1}} - {{atma.weapon}} </span></li>
</div>
我想这些切片的结果,每个div重复,每次使用从指数的3个项目。
I wanted to slice these results at, each div repeat, each time being used the 3 items from index.
因此,我将开始与展示范围从1到3武器的第一个div。
第二个将具有4至6个元素。
等等。
So I would start with the first div showing the weapons ranging from 1 to 3. The second one would have elements from 4 to 6. And so on.
我可以用$指数或类似的东西在我的片?
Can I use $index or something like that on my slice?
诗:这个问题来自试穿<一个我最好的href=\"http://stackoverflow.com/questions/27533682/repeating-a-determined-ammount-of-times-inside-another-ng-repeat\">this问题在这里。
我仍然有一些麻烦,但我做了基于什么我可以做切片另一个问题。
Ps.: This question came from trying my best on this question here. I'm still having some trouble, but I made another question based on what I could do with slice.
推荐答案
1
<div ng-repeat="atma in data">
<ul ng-if="$index % 3 == 0">
<li><span>{{data[$index]}} </span>
</li>
<li ng-if="$index+ 1 < data.length"><span>{{data[$index+1]}} </span>
</li>
<li ng-if="$index+ 2 < data.length"><span>{{data[$index+2]}} </span>
</li>
</ul>
</div>
2日:
<div ng-repeat="atma in data">
<ul ng-if="$index % 3 == 0" ng-init="tmp = data.slice($index, $index + 3)">
<li ng-repeat="atma1 in tmp"><span>{{atma1}}</span>
</li>
</ul>
</div>
http://plnkr.co/edit/Uo1ROo549swNorzixTi3?p=$p$ PVIEW
这篇关于通过切片与指数增量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!