1.2.2 • Published 7 years ago

pager-factory v1.2.2

Weekly downloads
5
License
MIT
Repository
github
Last release
7 years ago

Pager - A factory for pagination objects

Build Status Coverage Status Dependency Status

A component factory to handle pagination for you

How to get it ?

Manual Download

Download the from here

Bower

bower install pager-factory

npm

npm install -S pager-factory

Usage

  1. Add pager.js to your main file (index.html) or include it in your bundle

    <script type="text/javascript" src="bower_components/pager/dist/pager-factory.js"></script>
  2. Set pager as a dependency in your module

    var myApp = angular.module('myApp', ['pager'])
  3. Add pager directive to the wanted element and churn out pagers!

    myApp.controller('someCtrl', ['pager', function(pager) {
      var myPager = new pager(15);
    }]);
  4. See the API Ref for more details

Basic Example

angular
  .module('myApp', ['pager'])
  .controller('homeCtrl', function(pager, someService) {
    var myPager = new pager(15); //optionally set page size on construction
    
    var request = myPager.createPagedRequest(); // Generates a request with page number and size
    someService.asyncCall(request)
      .then(function(success) {
        // Add the new page of results and set the total count
        myPager.addPage(success.results, success.totalCount); 
      });
  });