mat-paginatoor控件

pageNumber是點擊搜索查詢後,跟新的變量值。spa

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;
}
相關文章
相關標籤/搜索