Angular Rows into Columns
by Venu Pavuluri
HTML
<div ng-app="myApp" ng-controller="MyCtrl">
<table>
<tr ng-repeat="key in keys">
<td>{{labels[key]}}</td>
<td ng-repeat="(index,data) in items">{{data[key]}}</td>
</tr>
</table>
</div>
JavaScript
var myApp = angular.module('myApp', []);
myApp.controller('MyCtrl', function ($scope) {
$scope.items = [
{id:"1",name:"testA", address:"1 MS WAY", city:"Redmond", state:"WA"},
{id:"2",name:"testB", address:"355 110th AVE NE", city:"Bellevue", state:"WA"},
];
$scope.keys = ["id","name","address","city", "state"];
$scope.labels = {id:"Id",
name:"Name",
address:"Address",
city:"City",
state:"State"
};
});