ProductPromotion
Logo

Angular.JS

made by https://0x3d.site

GitHub - sibiraj-s/angular-paginator: 📖 Pagination Component for Angular applications
📖 Pagination Component for Angular applications. Contribute to sibiraj-s/angular-paginator development by creating an account on GitHub.
Visit Site

GitHub - sibiraj-s/angular-paginator: 📖 Pagination Component for Angular applications

GitHub - sibiraj-s/angular-paginator: 📖 Pagination Component for Angular applications

Getting Started

edit in stackblitz

Installation

Install via package managers such as npm or yarn

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

Usage

Import the angular-paginator module

import { AngularPaginatorModule } from 'angular-paginator';

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

and in the template

<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

The angularPaginator pipe accepts

{
  id: 'ANGULAR_PAGINATOR_DEFAULT',
  itemsPerPage: 10,
  currentPage: currentPage
}
  • id: The default id is ANGULAR_PAGINATOR_DEFAULT when not specified. This is optional. Provide a unique id when multiple pagination instances are being used.
  • itemsPerPage: Number of items per page
  • currentPage: Current page number

[!IMPORTANT] When using an id, ensure to provide the same id in both the pipe and directive of the same instance.

Paginator Directive

<angular-paginator
  id="ANGULAR_PAGINATOR_DEFAULT"
  [maxSize]="5"
  [rotate]="true"
  [boundaryLinkNumbers]="false"
  [forceEllipses]="false"
  (pageChange)="currentPage = $event"
  #paginator="angularPaginator"
>
</angular-paginator>
  • id: The default id is ANGULAR_PAGINATOR_DEFAULT when not specified. This is optional. This must be provided if the id is specified in the pipe and should be the same as the pipe id
  • 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 maxSize is smaller than the number of pages, then the first and last page numbers are still shown with ellipses in-between as necessary.
  • forceEllipses: Also displays ellipses when rotate is true and maxSize is smaller than the number of pages

[!NOTE] maxSize 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

API

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

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory