1

i am using angular material table for angular 10 project. I added material table successfully. but now i am trying to add pagination to my table. therefor i added below code to my component.

import {MatPaginator} from '@angular/material/paginator';

i added above import to my app.module.ts file.

this is the code that i added for my html page to load pagination

 <mat-paginator [pageSizeOptions]="[5, 10, 20]" showFirstLastButtons></mat-paginator>

but this html tag did not work. it occurred error.

please check below image.

enter image description here

my modules enter image description here

CharybdeBE
  • 1,791
  • 1
  • 20
  • 35
kumara
  • 877
  • 4
  • 19
  • 43

1 Answers1

0

As stated by your IDE, the module doesn't know that component. The solution is to add it in your app.module.ts (or equivalent depending where your ar ein the app)

You should import the module MatPaginatorModule in your appmodule

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { MatPaginatorModule } from '@angular/material/paginator';
import { AppComponent } from './app.component';


@NgModule({
  declarations: [
    AppComponent,
  ],
  imports: [
    BrowserModule,
    MatPaginatorModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Note that i have imported the module and not the component directly

CharybdeBE
  • 1,791
  • 1
  • 20
  • 35