Angular material paginator has a method starting with _
.
_changePageSize(pageSize: number) {
// Current page needs to be updated to reflect the new page size. Navigate to the page
// containing the previous page's first item.
const startIndex = this.pageIndex * this.pageSize;
const previousPageIndex = this.pageIndex;
this.pageIndex = Math.floor(startIndex / pageSize) || 0;
this.pageSize = pageSize;
this._emitPageEvent(previousPageIndex);
}
This method is not listed in the Paginator API documentation. However it's refered in answers like this.
In the same paginator component, a method defined as private and not available in IDE.
private _updateDisplayedPageSizeOptions() {
if (!this._initialized) { return; }
// If no page size is provided, use the first page size option or the default page size.
if (!this.pageSize) {
this._pageSize = this.pageSizeOptions.length != 0 ?
this.pageSizeOptions[0] :
DEFAULT_PAGE_SIZE;
}
In AOT it gives error after successful compilation.
i 「wdm」: Compiled successfully.
ERROR in src/app/models/models.component.ts(153,22):
error TS2341: Property '_updateDisplayedPageSizeOptions' is private and only accessible within class 'MatPaginator'.
I understand _
by conventions refers private and no direct private method concept in Javascript. Just need more info on:
- Is that an internal method that should not be relied on?
- In angular (or in angular-material) what is the difference between a method that starts with
_
and regular method? - If it's changePageSize is not a private method why
_
suffix? If it's private method, why it's not marked as private? Is this inconsistency or something I'm missing here?