Angular: Empty Fiddle
http://angularjs.org/
HTML
<script src="http://code.angularjs.org/angular-1.0.1.js"></script>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<div ng-controller="MyCtrl">
<table class="table">
<thead>
<th ng-repeat="field in fields">{{field}}</th>
</thead>
<tr ng-repeat="row in rows">
<th ng-repeat="field in fields">{{getValue(field, row)}}</th>
</tr>
</table>
</div>
JavaScript
var myApp = angular.module('myApp', []);
function MyCtrl($scope, $parse) {
$scope.rows = [{
info: {
name: "Apple",
category: "Fruit"
},
rate: {
health: 100,
ignored: true
}
},{
info: {
name: "Orange",
category: "Fruit"
},
rate: {
health: 100,
ignored: true
}
},{
info: {
name: "Snickers",
category: "Sweet"
},
rate: {
health: 0,
ignored: true
}
}]
$scope.fields = ['info.name', 'info.category', 'rate.health'];
$scope.getValue = function(exp, row){
return $parse(exp)(row);
}
}