First of all, I know there have been several similar questions, but I have not managed to make it work the way I want it to. And it's the simplest thing anyone could ask from a paginator. Load the first page immediately, without having to press the next and previous buttons.
My HTML
<mat-paginator [length]="length"
[pageSize]="pageSize"
(page)="pageEvent = $event">
</mat-paginator>
<div *ngIf="pageEvent">
<mat-grid-list cols="2" rowHeight="7:1">
<ng-container>
<mat-grid-tile>
pageIndex = {{ pageEvent.pageIndex }}
</mat-grid-tile>
</ng-container>
</mat-grid-list>
</div>
and typescript
import { Component, OnInit, ViewChild } from '@angular/core';
import { PageEvent } from '@angular/material/paginator';
@Component({
selector: 'app-room',
templateUrl: './room.component.html',
styleUrls: ['./room.component.css']
})
export class RoomComponent implements OnInit {
// MatPaginator inputs
length = 6;
pageSize = 1;
// MatPaginator output
pageEvent: PageEvent;
constructor() { }
ngOnInit(): void {}
}
Answers from posts like this or this do not work.
Any help would be appreiated!
Edit: I posted the whole ts file.