sorttable.js没有对使用ng-repeat填充的列进行排序

时间:2018-04-04 07:28:59

标签: angularjs sorttable.js

<div id="collapseThree-2" class="panel-collapse collapsexpanded="false">
   <table class="table table-hover hd-bg table-bordered;sortable">
      <thead align="center">
         <tr>
            <th>Request ID</th>
            <th>Request Type</th>
            <th>Initiator</th>
            <th>Product</th>
            <th>Version</th>
            <th>Submission Date</th>
            <th>Stage</th>
         <tr>
      <tbody ng-repeat = "x in requestData">
         <td ng-bind = "x.id"></td>
         <td ng-bind = "x.type_of_request"></td>
         <td ng-bind = "x.initiator_name"></td>
         <td ng-bind = "x.product_name"></td>
         <td ng-bind = "x.product_version"></td>
         <td ng-bind = "x.submission_date"></td>
         <td ng-bind = "x.status_flag"></td>
      </tbody>
      </thead>
   </table>
</div>

在这里,我使用sottable.js,但仍然无法在列上找到排序选项。因为,我使用的是sorttable.js,所以默认情况下它需要在表的列上提供排序选项

1 个答案:

答案 0 :(得分:0)

你需要像这样绑定对象数组

$scope.sortColumn = {
   Column: 'c1', // name of column
   reverse: false // order 
};

html代码: -

<th ng-repeat="object in objects">
    <a ng-click="columnSort.sortColumn=objects[$index];columnSort.reverse=!columnSort.reverse">{{ objects[$index] }}</a>
</th>

please find fiddle