Skip to content

Instantly share code, notes, and snippets.

@rolaveric
Created September 2, 2015 12:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rolaveric/303477bb54b9ef125eb8 to your computer and use it in GitHub Desktop.
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.
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