Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
65
rated 0 times [  67] [ 2]  / answers: 1 / hits: 6330  / 10 Years ago, mon, april 7, 2014, 12:00:00

I have an array a=[1,2,3,4,5,6].



Using ng-repeat on this array, I am creating 6 divs.



Please refer to this plunker



Is there any way to add one more div after each row. So after 3 divs I want to add one extra div.



I looked into this example. but they are creating a child div. is it possible to create a sibling div in ng-repeat


More From » angularjs

 Answers
6

Let's try 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>


Please note that ng-repeat-start directive is included since angular 1.2.1.



plnkr demo



ng-repeat: repeat a series of elements of one parent element



<!--====repeater range=====-->
<Any ng-repeat=friend in friends>
</Any>
<!--====end of repeater range=====-->


ng-repeat-start & ng-repeat-end: using ng-repeat-start and ng-repeat-end to define the start point and end point of extended repeater range



<!--====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=====-->

[#46246] Friday, April 4, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rocky

Total Points: 316
Total Questions: 108
Total Answers: 110

Location: Mali
Member since Sat, Feb 12, 2022
2 Years ago
;