angularjs - access key and value from JSON array object

http://stackoverflow.com/questions/21697695/angularjs-ng-repeat-access-key-and-value-from-json-array-object#

by Damith Nuwan Sampath

HTML

<script src="http://code.angularjs.org/angular-1.0.1.js"></script>
<div ng-controller="MyCtrl">
    <table>
        <tr>
            <th ng-repeat="(key, val) in items[0]">{{key}}</th>
        </tr>
        <tr ng-repeat="item in items">
            <td ng-repeat="(key, val) in item">{{val}}</td>
        </tr>
    </table>
</div>

CSS

ul {
    
    border: solid 1px #404040;
    margin: 5px;
}

JavaScript

var myApp = angular.module('myApp', []);

function MyCtrl($scope) {
    $scope.items = [{
        Name: "Soap",
        Price: "25",
        Quantity: "10"
    }, {
        Name: "Bag",
        Price: "100",
        Quantity: "15"
    }, {
        Name: "Pen",
        Price: "15",
        Quantity: "13"
    }];
}