I'm new to angular and I try to create a table with pagination, the data returns from a server, so I don't want to bring all data together (because maybe I have more than thousands of rows), so which type of pagination you prefer to be good? I found out these two implementations: first:
<mat-paginator [pageSizeOptions]="[5, 10, 25, 100]"></mat-paginator>
second:
<mat-paginator [length]="length"
[pageSize]="pageSize"
[pageSizeOptions]="pageSizeOptions"
(page)="pageEvent = $event">
</mat-paginator>
I think the second is better but I don't know how to use it. Please help me and tell me how I can bring data from server only when I change the paginator for example at the beginning it only bring me 5 rows when I go to the next page it brings me another 5 rows from the server.
If you can please give me a simple example or a link which explained as easy as enough to understand.