Here's the answer. I'm not sure that this is exactly what you want, but I think it is close: http://plnkr.co/edit/ADKu2WEb9TyvEXASOJyz?p=preview
Note that I use ng-repeat-start / ng-repeat-end to handle the multi-line thing you want to do:
<body ng-app="example" ng-controller="ExampleController"> <table> <tr ng-repeat-start="row in data"> <td>{{ label(0) }}:</td> <td>{{ value(row, 0) }}</td> <td>{{ label(1) }}:</td> <td>{{ value(row, 1) }}</td> </tr> <tr ng-repeat-end> <td>{{ label(2) }}:</td> <td>{{ value(row, 2) }}</td> <td>{{ label(3) }}:</td> <td>{{ value(row, 3) }}</td> </tr> </table> </body>
The rest is just a super simple module and controller:
angular.module('example', []) .controller('ExampleController', function ($scope) { var fields = [ 'id', 'name', 'username', 'email', 'age' ]; $scope.data = [{id:1, name: 'john', username: 'john', age: 20, email: 'test'}]; $scope.label = function (fieldNumber) { return fields[fieldNumber]; }; $scope.value = function (row, fieldNumber) { return row[fields[fieldNumber]]; } });
source share