My HTML looks like this:
<div class="creations accordion" ng-repeat="creation in filteredCreations | orderBy : field : reverse">
[[creation.id]]
[[creation.name]]
</div>
In my Angular controller, I have the following setup:
var exampleApp = angular.module('exampleApp', ['ui.bootstrap']).config(function($interpolateProvider) {
$interpolateProvider.startSymbol('[[').endSymbol(']]');
});
exampleApp.controller('CreationController', ['$scope', '$filter', function($scope, $filter) {
$scope.currentPage = 1;
$scope.itemsPerPage = 2;
creations = $.map(creations, function(value, index) {
return [value];
});
$scope.creations = creations;
$scope.filteredCreations = [];
$scope.order = function(field) {
$scope.reverse = ($scope.field === field) ? !$scope.reverse : false;
$scope.field = field;
};
$scope.field = 'id';
$scope.reverse = false;
$scope.figureOutCreationsToDisplay = function() {
var begin = (($scope.currentPage - 1) * $scope.itemsPerPage)
, end = begin + $scope.itemsPerPage;
$scope.filteredCreations = $scope.creations.slice(begin, end);
};
$scope.figureOutCreationsToDisplay();
$scope.pageChanged = function() {
$scope.figureOutCreationsToDisplay();
};
}]);
I currently paginate the results and then display them, meaning the orderBy filter only sorts the data within the paginated set. However, I now want to sort all the data before pagination.
How can I achieve this?