”;
The <mat-paginator>, an Angular Directive, is used to show a navigator with paged information.
In this chapter, we will showcase the configuration required to show a paginator using Angular Material.
Following is the content of the modified module descriptor app.module.ts.
import { BrowserModule } from ''@angular/platform-browser''; import { NgModule } from ''@angular/core''; import { AppComponent } from ''./app.component''; import {BrowserAnimationsModule} from ''@angular/platform-browser/animations''; import {MatPaginatorModule} from ''@angular/material'' import {FormsModule, ReactiveFormsModule} from ''@angular/forms''; @NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule, BrowserAnimationsModule, MatPaginatorModule, FormsModule, ReactiveFormsModule ], providers: [], bootstrap: [AppComponent] }) export class AppModule { }
Following is the content of the modified HTML host file app.component.html.
<mat-paginator [length] = "100" [pageSize] = "10" [pageSizeOptions] = "[5, 10, 25, 100]" (page) = "pageEvent = $event"> </mat-paginator> <div *ngIf = "pageEvent"> <h5>Page Change Event</h5> <div>List length: {{pageEvent.length}}</div> <div>Page size: {{pageEvent.pageSize}}</div> <div>Page index: {{pageEvent.pageIndex}}</div> </div>
Result
Verify the result.
Details
- Here, we”ve created a paginator using mat-paginator and handles its change event.
Advertisements
”;