Git Product home page Git Product logo

ngpager's Introduction

NgPager

ng-pager is a pagination directive for your angular application. The directive is only dependent on AngularJs and has no dependencies on JQuery. For styling, you may use the supplied stylesheet, bootstrap or your own stylesheet.

Demo

Demo

Installation

Grab the latest release or use bower install --save ngpager

Add the javascript file:

<script type="text/javascript" src="ngpager.min.js"></script>

Then add NgPager to your module's dependencies:

angular.module('app', ['NgPager'])

Usage

Basic usage

<div ng-pager 
     current-page="{{currentPage}}" 
     total-pages="{{totalPages}}" 
     max-pages-to-display="{{maxPagesToDisplay}}" 
     page-changed="paged(pageNum)"
     enable-jump-controls="true"
     ></div>

Add the ng-pager directive to any div element and specify the current page, total pages and maximum pages to display. Also include a function to handle the page changed event in your controller. Note that the current page will only update when you update it in your model.

current-page (required)

An expression that should evaluate to the current page to be displayed

total-pages (required)

An expression that evaluates to the total number of pages in the list

max-pages-to-display (optional)

An expression that evaluates to the maximum number of pages that are displayed at a time. If this is not specified then the directive defaults to the value in the global config. If that is not configured then a default of 3 is used.

page-changed (required)

Takes a function that is called everytime a page change is requested. The function is passed as a parameter the selected page number.

enable-jump-controls (optional)

When set, the directive will always display the first and last page. By default these are hidden. You can override this in the configuration described below.

Configuration

angular.module('TestApp', ['NgPager'])
.run(function(PagerConfig)
{ 
	PagerConfig.setBase1();
	PagerConfig.enableJumpControls();
})

By default, the directive uses base 0 for page numbers. That means that the first page has index 0. If you want to change it to index 1, you can call setBase1() on the configuration. To configure the directive to always display the first and last page you can call enableJumpControls(). To set a global default of the number of pages to be displayed, use setDefaultMaxPages(desiredDefault).

ngpager's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.