Created
September 2, 2015 12:38
-
-
Save rolaveric/303477bb54b9ef125eb8 to your computer and use it in GitHub Desktop.
Example of a pageRange filter that can be used with FalcorJS to handle a range of values.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function pageRangeFilterProvider() { | |
return function pageRangeFilter(itemCount, currentPage, pageSize) { | |
itemCount = itemCount || 0; // The 'length' of the collection | |
currentPage = currentPage || 1; // The current page number being viewed | |
pageSize = pageSize || 5; // The size of each page | |
const range = []; | |
for (var x = (currentPage - 1) * pageSize; x < currentPage * pageSize && x < itemCount; x++) { | |
range.push(x); | |
} | |
return range; | |
}; | |
} | |
angular.module('falcorExample') | |
.filter('pageRange', pageRangeFilterProvider); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment