Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular material Paginator is not working

I am trying to add Angular Material Paginator on my app.

MatPaginatorModule added in module.

<mat-paginator #paginator                 [length]="100"                 [pageSize]="10"                 [pageSizeOptions]="[5, 10, 25, 100]"> </mat-paginator> 

But It gives a Error:

Uncaught Error: Template parse errors:

Can't bind to 'length' since it isn't a known property of 'mat-paginator'.

  1. If mat-paginator is an Angular component and it has length input, then verify that it is part of this module.
  2. If mat-paginator is a Web Component then add CUSTOM_ELEMENTS_SCHEMA to the @NgModule.schemas of this component to suppress this message.

Maybe i am missing something?

"@angular/animations": "^5.0.1", "@angular/cdk": "^5.0.0-rc0", "@angular/common": "^5.0.0", "@angular/compiler": "^5.0.0", "@angular/core": "^5.0.0", "@angular/forms": "^5.0.0", "@angular/http": "^5.0.0", "@angular/material": "^5.0.0-rc0", 
like image 256
Umar Farooq Aslam Avatar asked Dec 12 '17 14:12

Umar Farooq Aslam


People also ask

What is paginator in Angular?

The paginator displays a dropdown of page sizes for the user to choose from. The options for this dropdown can be set via pageSizeOptions. The current pageSize will always appear in the dropdown, even if it is not included in pageSizeOptions.

How pagination works in Angular?

The pagination component is bound to items property of the app component using the Angular model binding attribute [items]="items" , and is bound to the onChangePage() method of the app component using the Angular event binding attribute (changePage)="onChangePage($event)" .

Can't bind to length since it isn't a known property of Mat Paginator?

Uncaught Error: Template parse errors: Can't bind to 'length' since it isn't a known property of 'mat-paginator'. If mat-paginator is an Angular component and it has length input, then verify that it is part of this module. If mat-paginator is a Web Component then add CUSTOM_ELEMENTS_SCHEMA to the @NgModule.


1 Answers

Just in case someone else runs into this problem, all it takes is importing the module in app.module.ts

import { MatPaginatorModule } from '@angular/material'; 

and

@NgModule({ ... imports: [  .... MatPaginatorModule ] 
like image 95
Daniel Avatar answered Oct 04 '22 16:10

Daniel