1.0.2 • Published 5 years ago

rg-pagination-lib v1.0.2

Weekly downloads
15
License
-
Repository
-
Last release
5 years ago

Pagination (Angular)

Simple-2-use custom made pagination component for angular.

Installation

Install rg-pagination-lib with npm:

$ npm install --save rg-pagination-lib

Usage

<rg-pagination
  [currentPage]="currentPage"
  [count]="count"
  [itemsPerPageList]="itemsPerPageList"
  [selectedItemPerPage]="selectedItemPerPage"
  (goPrev)="goToPrev()"
  (goNext)="goToNext()"
  (goToItemPerPage)="goToItemPerPage($event)"
></rg-pagination>

Steps to Follow

  • Add below link in index.html file.
 <link
  rel="stylesheet"
  href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"
/>
  • Import rg-pagination-lib module in app.module.ts file.
import { RgPaginationLibModule } from 'rg-pagination-lib';

imports: [
  ...,
    RgPaginationLibModule
  ],
  • In app.component.html , add the following
<rg-pagination
  [currentPage]="currentPage"
  [count]="count"
  [itemsPerPageList]="itemsPerPageList"
  [selectedItemPerPage]="selectedItemPerPage"
  (goPrev)="goToPrev()"
  (goNext)="goToNext()"
  (goToItemPerPage)="goToItemPerPage($event)"
></rg-pagination>
  • In app.component.ts , add the following
export class AppComponent {
  public currentPage = 1; 
  public count = 100; 
  public selectedItemPerPage; //default value is 10
  public itemsPerPageList = [10, 20, 50, 100, 500]; //default value
  title = 'app-component';
  goToItemPerPage(event) {
    this.selectedItemPerPage = event;
  }
  goToPrev() {
      console.log('IN Previous');
  }
  goToNext() {
      console.log('IN Next');

  }
}
  • Final Result looks like

Look of rg-pagination

Total Items: {{ count }} Items per page: {{ selectedItemsPerPage }} Showing 1 - {{ pagesToShow }} of {{ currentPage }}

Params

NameTypeDescription
currentPageNumberShows which page is currently opened from PageList
countNumberShows Total Count of items present
pagesToShowNumberShows PageList derived automatically from selectedItemPerPage/count (i.e., Pages between Previous and Next) (Reference purpose)
itemsPerPageListNumber Shows List of Items Per Page
selectedItemPerPageNumberShows selected Items Per Page
goPrevfn()Click on Previous Arrow will call this function
goNextfn()Click on Next Arrow will call this function
goToItemPerPagefn()Click on ItemsPerPage List will call this function

Happy Coding ! :stuck_out_tongue_closed_eyes:

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.0.1

5 years ago