Want to split the ng-repeat data with three columns using bootstrap? Use the below example to split the ng-repeat data with three columns using bootstrap.
HTML Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <div ng-controller="MyCtrl"> <table style="width:100%"> <tr ng-repeat="item in items" ng-switch on="$index % 3"> <td ng-switch-when="0"> {{items[$index].id}} {{items[$index].name}} </td> <td ng-switch-when="0"> <span ng-show="items[$index+1]"> {{items[$index+1].id}} {{items[$index+1].name}} </span> </td> <td ng-switch-when="0"> <span ng-show="items[$index+2]"> {{items[$index+2].id}} {{items[$index+2].name}} </span> </td> </tr> </table> </div> |
JS code:
1 2 3 4 5 | var myApp = angular.module('myApp', []); function MyCtrl($scope) { $scope.items = [{id:"1",name:"testA"},{id:"2",name:"test B"},{id:"3",name:"test C"},{id:"4",name:"test D"},{id:"5",name:"test E"}]; } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.