Socket
Socket
Sign inDemoInstall

ngx-pager

Package Overview
Dependencies
5
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ngx-pager

A pagination plugins for **Angular**.


Version published
Maintainers
1
Created

Readme

Source

ngx-pager

A pagination plugins for Angular.

Build Status Support Support Support Support Support License

Please support this project by simply putting a Github star. Share this library with friends on Twitter and everywhere else you can.

Table of contents:

Getting started

Installation

npm install ngx-pager --save

Implementation

import "NgxPagerModule" in your application module. For example: app.module.ts

import {NgxPagerModule} from  'ngx-pager';
@NgModule({
    imports:[
	    NgxPagerModule
	    ...
    ]
})
export  class  AppModule { }

add styles in your application stylesheets. For example: styles.scss

@import  "~ngx-pager/themes/ngx-pager";

add configration in your component. For example : app.component.ts

import {HttpClient} from  '@angular/common/http';

export  class  AppComponent  implements  OnInit {
pagerConfig: any = null;
totalRow: any = null;
result: Array<any> = [];

constructor(private  http:  HttpClient){}
ngOnInit() {
   this.pagerConfig  = {
	    perPage:3,
		displayPageCount:  3,
		firstLastView:true,
		    render: (page)=> {
				this.http.get('<API URL>')
				.subscribe((responseData:any)=>{
					this.totalRow = responseData.totalRows;
					this.result = responseData.list;
				})
			}
		};
    }
}

			

If want to change the url with query string after every page change, append redirect parameter with config.For example: url like http://localhost:4200/home?page=1

redirect : {
  type :'q', // q=query string
  param : 'page'// param name
},

If want to change the url with url parames after every page change, append redirect parameter with config. For example: url like http://localhost:4200/home/flag-one/1/flag-two

redirect: {
	type :  'p',
	param: {
		path :  './home',
		name :  'page',
		params: {
		    flagOne: 'flag-one',
			page:  null,
			flagTwo: 'flag-two'
		}
   }
},

Add ngx-pager html tag in your component html. For example : app.component.html

<ngx-pager  [config]="pagerConfig"  [totalrow]='totalRow'></ngx-pager>
  • [config] : to set the pagination configuration
  • [totalrow]: to set the total rows of data list

Settings Option

DescriptionDefault ValueRequired
perPagenumber of records display in every pageyes
displayPageCountnumber of pages show in pagination panel3
simpleonly show next and prev buttonsfalse
firstLastViewfirst last buttons will displayfalse
redirectredirection configuration after click on page button
redirect.typepage render with query string or page parameterq=query string, p= url paramsyes
redirect.paramif redirect.type=q name of the query string parameter. For example: http://current-url?page=1. redirect.param='page'yes
redirect.param.pathif redirect.type=p name of the url. for example: redirect.param.path='./home'yes(only redirect.type=p)
redirect.param.nameif redirect.type=p name of the url params which content the page no. for example: http://current-url/{page}/{slug_1}/{slug_2}. redirect.param.name='page'yes(only redirect.type=p)
redirect.param.paramsif redirect.type=p all url params list. it's object type data. For example: redirect.param.params = { "page":null, "slug_1":"cont-1", "slug_2":"cont-2" }yes(only redirect.type=p)
customContentto change the prev,next,first,last button html{"prev":"&#10094;", "next":"&#x276F;", "first":"&#10094; &#10094;", "last":"&#x276F; &#x276F;"}
renderevent to rendering the list with paginnationyes

Demo

Click Here for the demo

Creator

Tonmoy Nandy

License

The MIT License (MIT)

Keywords

FAQs

Last updated on 05 Aug 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc