
pageNumber是点击搜索查询后,跟新的变量值。

import { MatPaginatorIntl } from '@angular/material';
const getRangeLabel = (page: number, pageSize: number, length: number) => {
if (length === 0 || pageSize === 0) {
return '无数据';
}
length = Math.max(length, 0);
const startIndex = page * pageSize;
const endIndex = startIndex < length ? Math.min(startIndex + pageSize, length) : startIndex + pageSize;
return '第' + (startIndex + 1) + ' - ' + endIndex + '条,共 ' + length + '条';
}
export function myPaginator() {
const p = new MatPaginatorIntl();
p.itemsPerPageLabel = '每页条数';
p.nextPageLabel = '下一页';
p.previousPageLabel = '上一页';
p.firstPageLabel = '第一页';
p.lastPageLabel = '最后一页';
p.getRangeLabel = getRangeLabel;
return p;
}
本文介绍如何在Angular项目中使用MatPaginator组件,并自定义其显示文本,包括每页条数、上一页、下一页等标签,以及实现分页范围的中文显示。

被折叠的 条评论
为什么被折叠?



