npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

angular-paginator

v11.0.0

Published

Pagination for Angular Applications

Downloads

1,824

Readme

Getting Started

edit at stackblitz | demo on stackblitz

Installation

Install via Package managers such as npm or yarn

npm install angular-paginator --save
# or
yarn add angular-paginator

Usage

Import angular-paginator module

import { AngularPaginatorModule } from 'angular-paginator';

@NgModule({
  imports: [AngularPaginatorModule],
})
export class AppModule {}

Then in HTML

<div *ngFor="let item of array | angularPaginator: { currentPage: currentPage }; let i = index">
  {{(currentPage - 1) * itemsPerPage + i +1}}. {{item}}
</div>

<angular-paginator (pageChange)="currentPage = $event"></angular-paginator>

Paginator Pipe

angularPaginator pipe accepts

{
  id: 'ANGULAR_PAGINATOR_DEFAULT',
  itemsPerPage: 10,
  currentPage: currentPage
}

Paginator Directive

<angular-paginator
  id="ANGULAR_PAGINATOR_DEFAULT"
  [maxSize]="5"
  [rotate]="true"
  [boundaryLinkNumbers]="false"
  [forceEllipses]="false"
  (pageChange)="currentPage = $event"
  #paginator="angularPaginator"
>
</angular-paginator>
  • id: Use unique id when multiple paginations are being used on the same page
  • maxSize: Limit number for pagination size
  • rotate: Whether to keep the current page in the middle of the visible ones
  • boundaryLinkNumbers: Whether to always display the first and last page numbers. If max-size is smaller than the number of pages, then the first and last page numbers are still shown with ellipses in-between as necessary. NOTE: max-size refers to the center of the range. This option may add up to 2 more numbers on each side of the displayed range for the end value and what would be an ellipsis but is replaced by a number because it is sequential
  • forceEllipses: Also displays ellipses when rotate is true and maxSize is smaller than the number of pages

You can get access to the pagination instance(directive's api) using #paginator="angularPaginator". The following are the methods/properties available via the API

  • pages - Array of page objects.
interface Page {
  number: number;
  text: string;
  active: boolean;
}
  • toPreviousPage() - Sets the current page to previous (currentPage - 1)
  • toNextPage() - Sets the current page to next (currentPage + 1)
  • toFirstPage() - Sets the first page as current
  • toLastPage() - Sets the last page as current
  • setCurrentPage(val) - Sets the given page as current page.
  • currentPage - Returns the current page number
  • firstPage - Returns the first page number
  • lastPage - Returns the last page number