I have the following data and HTML template (and other code in app.js obviously). The code in my "tbody" works perfectly, and displays a table like this:
current output
--------------------
| AAPL | 127 | 128 |
--------------------
| GOOG | 523 | 522 |
--------------------
| TWTR | 35 | 36 |
--------------------
Now I'm trying to loop through the 'keys' of the first object and display them in a 'thead' like so:
desired output
--------------------
| Name | jan | feb |
--------------------
| AAPL | 127 | 128 |
--------------------
| GOOG | 523 | 522 |
--------------------
| TWTR | 35 | 36 |
--------------------
data
$scope.data = [
{
"name": "AAPL",
"jan": "127",
"feb": "128"
},
{
"name": "GOOG",
"jan": "523",
"feb": "522"
},
{
"name": "TWTR",
"jan": "35",
"feb": "36"
}]
html
<table>
<thead>
<tr>
<td ng-repeat="">{{}}</td>
</tr>
</thead>
<tbody>
<tr ng-repeat="object in data">
<td ng-repeat="(a,b) in object">{{b}}</td>
</tr>
</tbody>
</table>
It has been pointed out that this question is a duplicate of another one, although, the other one is in plain JS, this one uses AngularJS.