Zxxxxx
Zxxxxx

Reputation: 417

OrderBy in dirpaginate

I have the following code to populate the table:-

<tr dir-paginate="user in newBillValue|filter:search4|orderBy:['bill_time','bill_id']|itemsPerPage:10" pagination-id="NewBills">

I want the table to be ordered by bill_time descending order and bill_id ascending order. How can this be done.

Upvotes: 1

Views: 727

Answers (1)

Jonathan Buchan
Jonathan Buchan

Reputation: 29

In AngularJS there is a sort function available out of the box: However I am personally still looking for a solution to apply the sort across all pages in the dir-paginate without vanilla JS, perhaps vanilla is the best way though.

AngularJS orderBy https://docs.angularjs.org/api/ng/filter/orderBy

JS

$scope.sortBy = function(propertyName) {
$scope.reverse = ($scope.propertyName === propertyName) ? !$scope.reverse : false;
$scope.propertyName = propertyName;};

HTML

<th>
 <button ng-click="sortBy('name')">Name</button>
 <span class="sortorder" ng-show="propertyName === 'name'" ng-class="{reverse: reverse}"> 
 </span>
</th>

Upvotes: 0

Related Questions