小编mah*_*.gh的帖子

如何在绑定到 API 响应的角度材料表中添加分页

我是角度新手。在我的项目中显示了产品列表及其正常工作。

我的 HTML 代码如下:

<table mat-table [dataSource]="list_product" style="width: 20%;">
    <!-- id Column -->
    <ng-container matColumnDef="id" style="width: 20%;">
        <th mat-header-cell *matHeaderCellDef style="align-items: center;"> id </th>
        <td mat-cell *matCellDef="let list_product"> {{list_product.id}} </td>
    </ng-container>

    <!-- description Column -->
    <ng-container matColumnDef="description">
        <th mat-header-cell *matHeaderCellDef> Name </th>
        <td mat-cell *matCellDef="let list_product"> {{list_product.description}} </td>
    </ng-container>

    <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
    <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>
<mat-paginator [pageSizeOptions]="[5, 10, 20]" showFirstLastButtons></mat-paginator>
Run Code Online (Sandbox Code Playgroud)

我的 TypeScript 代码是 -

import { Component, OnInit,ViewChild } from '@angular/core';
import { HttpClient } from …
Run Code Online (Sandbox Code Playgroud)

pagination angular-material angular

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

angular ×1

angular-material ×1

pagination ×1