我有一个数组a=[1,2,3,4,5,6]
.
Using ng-repeat
在这个数组上,我创建了 6 个divs
.
请参考这个plunker http://plnkr.co/edit/fe4nTUFQ9ojEyBsyrOtH?p=preview
有没有什么办法可以再添加一个div
每行之后。所以在 3 个 div 之后我想添加一个额外的div
.
我调查了this https://stackoverflow.com/questions/21351988/angular-js-ng-repeat-and-loop-conditions例子。但他们正在创造一个孩子div
。是否可以创建一个兄弟姐妹div
NG重复
让我们尝试一下 ng-repeat-start 和 ng-repeat-end。
<div class="example-animate-container">
<div class="square" ng-repeat-start="friend in a">
{{$index}}
</div>
<div ng-if="$index % 3 == 2" ng-repeat-end>
extra div
</div>
</div>
请注意,从 Angular 1.2.1 开始就包含了 ng-repeat-start 指令。
plnkr 演示 http://plnkr.co/edit/IWCymJuCK5ShXtFGxX63?p=preview
ng-重复:重复“一个”父元素的一系列元素
<!--====repeater range=====-->
<Any ng-repeat="friend in friends">
</Any>
<!--====end of repeater range=====-->
ng-repeat-start 和 ng-repeat-end:使用 ng-repeat-start 和 ng-repeat-end 定义扩展中继器范围的起点和终点
<!--====repeater range start from here=====-->
<Any ng-repeat="friend in friends" ng-repeat-start>
{{friend.name}}
</Any><!-- ng-repeat element is not the end point of repeating range anymore-->
<!--Still in the repeater range-->
<h1>{{friend.name}}</h1>
<!--HTML tag with "ng-repeat-end" directive define the end point of range -->
<footer ng-repeat-end>
</footer>
<!--====end of repeater range=====-->
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)