简体   繁体   English

角度材料表分页问题角度 10

[英]angular material table pagination issue angular 10

i am using angular material table for angular 10 project.我正在将角材料表用于角 10 项目。 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.我将上面的导入添加到我的 app.module.ts 文件中。

this is the code that i added for my html page to load pagination这是我为 html 页面添加的用于加载分页的代码

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

but this html tag did not work.但是这个 html 标签不起作用。 it occurred error.它发生错误。

please check below image.请检查下图。

在此处输入图片说明

my modules我的模块在此处输入图片说明

As stated by your IDE, the module doesn't know that component.正如您的 IDE 所述,该模块不知道该组件。 The solution is to add it in your app.module.ts (or equivalent depending where your ar ein the app)解决方案是将它添加到您的 app.module.ts (或等效的,取决于您在应用程序中的位置)

You should import the module MatPaginatorModule in your appmodule您应该在MatPaginatorModule中导入模块 MatPaginatorModule

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请注意,我已直接导入模块而不是组件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM