5 changed files with 53 additions and 4 deletions
@ -0,0 +1,29 @@ |
|||||||
|
import { MatPaginatorIntl } from '@angular/material/paginator'; |
||||||
|
|
||||||
|
|
||||||
|
const dutchRangeLabel = (page: number, pageSize: number, length: number) => { |
||||||
|
if (length === 0 || pageSize === 0) { return `0 到 ${length}`; } |
||||||
|
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 paginatorIntl = new MatPaginatorIntl(); |
||||||
|
|
||||||
|
paginatorIntl.itemsPerPageLabel = '每页条数:'; |
||||||
|
|
||||||
|
paginatorIntl.nextPageLabel = '下一页:'; |
||||||
|
|
||||||
|
paginatorIntl.previousPageLabel = '上一页:'; |
||||||
|
|
||||||
|
paginatorIntl.getRangeLabel = dutchRangeLabel; |
||||||
|
|
||||||
|
return paginatorIntl; |
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue