Server-side pagination with ngx-pagination in Angular

Server-side pagination with ngx-pagination in Angular

In this article, I will explain how to do server-side pagination in Angular apps using ngx-pagination. Server-side pagination is returning

Server-side pagination is returning a subset of data requested by a client if you don’t want to display all data at once. The server takes a certain parameter from the client to get relevant information/records. In this article, I will explain how to do server-side pagination in  Angular apps using ngx-pagination.

Prerequisites for this tutorial

  1. Basic HTML, CSS, and JavaScript knowledge
  2. Angular knowledge including integration

ngx-pagination

ngx-pagination is a simple package(solution) for pagination in angular. It allows paging (displaying a subset of data by page).

Getting started with ngx-pagination.

Installing the package is as simple as running

npm install ngx-pagination --save

Copy

After installation, import NgxPaginationModule to your app module or any module you’ll like to use the package. See the example below;

// app.module.ts
import {NgxPaginationModule} from 'ngx-pagination'; // <-- import the module

@NgModule({
    imports: [
 NgxPaginationModule // <-- include it in your app module
], 

})

Copy

In the component file, add the following code

collection: any;
p: number;
  constructor( private http: HttpClient) {}

  ngOnInit() {
this.getAllData();
  }

  getAllData() {
      const url = "https://api.instantwebtools.net/v1/passenger";
    this.http.get(url).subscribe((data: any) => {
      console.log(data);
      this.collection =  data;
    })
  };
}

angular ngx-pagination

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Angular 11 Pagination Example with ngx-pagination

In this tutorial, I will show you how to make Angular 11 Pagination example with existing API (server-side pagination) using ngx-pagination. Other versions: – Angular 8 Pagination example | ngx-pagination – Angular 10 Pagination example | ngx-pagination Related Posts: – Angular 11 CRUD Application example with Web API – Angular 11 File upload example with […]

Visualizing data with NGX-Charts in Angular

Data Science, Data Analytics, Big Data, these are the buzz words of today's world. A huge amount of data is being generated and analyzed every day. So communica

Install Angular - Angular Environment Setup Process

Install Angular in easy step by step process. Firstly Install Node.js & npm, then Install Angular CLI, Create workspace and Deploy your App.

Angular 11 Pagination example with ngx-pagination

In this tutorial, I will show you how to make Angular 11 Pagination example with existing API (server-side pagination) using ngx-pagination. Other versions: – Angular 8 Pagination example | ngx-pagination – Angular 10 Pagination example | ngx-pagination Related Posts: – Angular 11 CRUD Application example with Web API – Angular 11 File upload example with […]

Angular 10 Pagination Tutorial with ngx-pagination Example

This is a comprehensive Angular 10 Pagination tutorial. In this tutorial, we will learn how to add server-side pagination in the Angular 10 data table. To add pagination in Angular, we will use the ngx-pagination package. Angular 10 Pagination Tutorial with ngx-pagination Example