0
如何對給定動態標題的表格進行排序?我可以找到的所有例子都使用靜態頭文件。我的第一個問題是ng-click沒有更新orderByField。有動態標題的角度排序
我下面BEST SHOT: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;
感謝