Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to insert <br> tag in ng-repeat angular-js after every 5 elements

Tags:

angularjs

While Using ng-repeat , I need to print only 5 in a row

I have tried as shown below

<div ng-app="myApp" ng-controller="myCtrl">
  <div ng-repeat="n in names">
      <input type="checkbox" ng-click="select(n)"/>{{n}}
        <br ng-if="($n+1)%5==0">
  </div> 

</div>

But all the rows are getting printed in a single row

http://jsfiddle.net/9fR23/474/

like image 752
Pawan Avatar asked Jan 05 '23 00:01

Pawan


2 Answers

You could have it like this:

<div ng-repeat="n in names" style="display: inline">
  <input type="checkbox" ng-click="select(n)"/>{{n}}
  <div ng-show="($index + 1) % 5 === 0">
    <br>
  </div>
</div> 

working fiddle

like image 134
tanmay Avatar answered Jan 13 '23 14:01

tanmay


<div ng-app = "myApp" ng-controller="myCtrl">

<div ng-repeat="n in names">     
<input type="checkbox" ng-click="select(n)"/>
 <br ng-if="($index+1)%5==0">
</div> 
</div>
like image 23
ashok Avatar answered Jan 13 '23 13:01

ashok