Skip to content

Angular.js Directive for Twitter Bootstrap's Pagination Component

License

Notifications You must be signed in to change notification settings

wadetandy/bb-paginate

Repository files navigation

For Standard Pagination:

<div bb-paginate="paginationData"
on-page-select="myFunctionOnScope(pageNumber)" />

Where paginationData MUST have attributes:

  • current_page
  • total_entries
  • per_page

Customizing:

Custom Paginator

Supply your own Paginator. This should subclass Paginator.

StandardPaginator, already a descendent of Paginator, can probably be easily overriden for most use cases.

Example:

Say you don't want to show prev/next arrows, and the initial number of pages ('left' window) should be 10 instead of 5):

app.factory 'MyCustomPaginator', ['StandardPaginator', (StandardPaginator) ->
  class MyCustomPaginator extends StandardPaginator
    constructor: (args...) ->
      super
      @windowSize.left = 10

    showNextPage: => false
    showPrevPage: => false
]
<div bb-paginate="paginationData" paginator="MyCustomPaginator" />

Controller API

BbPaginate also features a controller that can be leveraged by other components that wish to extend or hook into the basic functionality.

onPageSelect()

app.directive 'paginateBeacon', ($http) ->
  require: 'bbPaginate'
  link: ($scope, $element, $attrs, bbPaginateCtrl) ->
    bbPaginateCtrl.onPageSelect (pageNum) ->
      $http.get("/page_changed?page=#{pageNum}")
<div bb-paginate="paginationData" paginate-beacon />

About

Angular.js Directive for Twitter Bootstrap's Pagination Component

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published