如何在给定带角度的动态标题的情况下对表格进行排序?我可以找到的所有示例都使用静态标头。我的第一个问题是ng-click没有更新orderByField。
我在下面的最佳镜头:HTML:
<table class="table table-condesnsed table-bordered">
<thead>
<tr>
<th ng-repeat="header in report_headers"
ng-click="orderByField[header]; reverseSort = !reverseSort">
{{ header }}</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="quote in paginated_quotes">
<td ng-repeat="elem in quote |orderBy:orderByField:reverseSort">
<span ng-if="!isNumber(elem.value)">
{{ elem.value | limitTo:8 }}... {{ elem.unit }}</span>
<span ng-if="isNumber(elem.value)">
{{ elem.value | number:0 }} {{ elem.unit }}</span>
</td>
</tr>
</tbody>
</table>
JS:
$scope.orderByField = 'UUID';
$scope.reverseSort = false;
由于
答案 0 :(得分:0)
我想你想要
<th ng-repeat="header in report_headers"
ng-click="orderByField = header; reverseSort = !reverseSort">
除此之外看起来它应该起作用