I generated table data and table columns dynamically in angularjs. My table is
Name Hobby
XXXX Music
XXXX Cricket
XXXX Books
YYYY Tennis
YYYY Books
YYYY Drawing
But I want my table to be displayed like this :
Name Hobby
XXXX
Music
Cricket
Books
YYYY
Tennis
Books
Drawing
I used the following code to generate table :
<tr>
<th ng-repeat="th in keys">{{th}}</th>
</tr>
<tr ng-repeat="x in data ">
<td ng-repeat="th in keys">
{{ x[th]}}
</td>
</tr>
My json looks like this
[{"Name:"XXXX", "Hobby":"Music"},
{"Name:"XXXX", "Hobby":"Cricket"},
{"Name:"XXXX", "Hobby":"Books"},
{"Name:"YYYY", "Hobby":"Tennis"},
{"Name:"YYYY", "Hobby":"Books"},
{"Name:"YYYY", "Hobby":"Drawing"}]
I can't use similar to this
<ng-repeat="(key, value) in players | groupBy: 'team'">
because my table headers are created dynamically
How I can do this in angularjs?