Feature request.
I'd expect at least an example showing how to use MatPaginatorIntl
and if possible, an example showing, how we (developers) change the labels at runtime (useful for multilingual apps).
There are no examples.
1.Create a customIntl extends MatPaginatorIntl.You can replace lables of you own.
export class CustomMatPaginatorIntl extends MatPaginatorIntl {
itemsPerPageLabel = 'number of page';
nextPageLabel = 'next';
previousPageLabel = 'previous';
getRangeLabel = function (page, pageSize, length) {
if (length === 0 || pageSize === 0) {
return '0 od ' + length;
}
length = Math.max(length, 0);
const startIndex = page * pageSize;
// If the start index exceeds the list length, do not try and fix the end index to the end.
const endIndex = startIndex < length ?
Math.min(startIndex + pageSize, length) :
startIndex + pageSize;
return startIndex + 1 + ' - ' + endIndex + ' / ' + length;
};
}
2.add a customIntl to you module where you import the MatPaginator.
imports: [
...
MatPaginatorModule,
],
providers: [
...
{provide: MatPaginatorIntl, useClass: CustomMatPaginatorIntl}
]
Thanks for the example, however I'm asking for it to be documented, so every ppl can access this in https://material.angular.io/paginator. (Also the support for change labels at runtime if possible).
Can this whole thing better be replaced with something better? The solution to create a seperate internationalization file for every component in angular material seems insane for just translating a few strings. Why cant this be exposed as an object property to the normal paginator directive ..
Most helpful comment
1.Create a customIntl extends MatPaginatorIntl.You can replace lables of you own.
2.add a customIntl to you module where you import the MatPaginator.