I have a list of object like this :
var entryList = [
{
"Key1": "Value1",
"Key2": "Value2",
"Key3": "Value3"
},
{
"Key1": "Value1",
"Key2": "Value2",
"Key3": "Value3"
},
{
"Key1": "Value1",
"Key2": "Value2",
"Key3": "Value3"
}
]
And I want to create a HTML tab like this :
+--------+--------+--------+
| Key1 | Key2 | Key3 |
+--------+--------+--------+
| Value1 | Value2 | Value3 |
| Value4 | Value5 | Value6 |
| Value7 | Value8 | Value9 |
+--------+--------+--------+
And sort the values by key when we click on the header
3/4 of the code is in the html
<table class="table table-bordered table-striped">
<thead>
<tr>
<td ng-repeat="(key, value) in $ctrl.entryList[0]">
<a ng-click="$ctrl.sortType = key; $ctrl.sortReverse = !$ctrl.sortReverse">
{{key}}
<span ng-show="$ctrl.sortType == key && !$ctrl.sortReverse" class="fa fa-caret-down"></span>
<span ng-show="$ctrl.sortType == key && $ctrl.sortReverse" class="fa fa-caret-up"></span>
</a>
</td>
</tr>
</thead>
<tbody>
<tr ng-repeat="itemFormData in $ctrl.entryList | orderBy:sortType:sortReverse | filter:searchForm">
<td ng-repeat="(key, value) in itemFormData">{{ itemFormData[key] }}</td>
</tr>
</tbody>
</table>
The table is correctly displayed but when I click on the header to sort the column nothing happens. If you have some suggestions and thank you for your time.