I have an HTML table and want to sort my records ($scope.records
in ctrl) by clicking on table headers ($scope.headers
in ctrl),
Can anyone explain why does that work:
<th>
<a ng-click=sortColumn=headers[0];reverse=!reverse>{{ headers[0] }}</a>
</th>
<th>
<a ng-click=sortColumn=headers[1];reverse=!reverse>{{ headers[1] }}</a>
</th>
And that doesn't:
<th ng-repeat=header in headers>
<a ng-click=sortColumn=headers[$index];reverse=!reverse>{{ headers[$index] }}</a>
</th>
Here is the code for the records:
<tr ng-repeat=arr in records | orderBy:sortColumn:reverse>
<td ng-repeat=val in arr ng-bind-html-unsafe=arr[headers[$index]]</td>
</tr>
I have 58 columns in my table so would be much better to loop through the table headers...