here i have a issue while working with angular paginator . here i am getting data like below
Response One:
{
"Tabledata": [
{
"firstName":"Samuel",
"lastName":"Smith"
},
{
"firstName":"Sanu",
"lastName":"Smith"
}
],
"paging": {
"RecordsCount": 2,
"token": "JhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"
}
}
Response Two: I am getting total records count as 50
{
'RecordsCount' : 50
}
Now in the initial call the i am calling api and the api format is below
Initial Call
http://some api.com/data?searchParams=&pageSize=2&token=
After calling this i will get response like below
{
"Tabledata": [
{
"firstName":"Samuel",
"lastName":"Smith"
},
{
"firstName":"Sanu",
"lastName":"Smith"
}
],
"paging": {
"RecordsCount": 2,
"token": "JhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"
}
}
and after pressing the next button the api should initiate another http call and use this token and send it params for the same api like below
2nd call
http://some api.com/data?searchParams=&pageSize=2&token=JhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9
After this call i will get again same response but here token changes
{
"Tabledata": [
{
"firstName":"Samuel",
"lastName":"Smith"
},
{
"firstName":"Sanu",
"lastName":"Smith"
}
],
"paging": {
"RecordsCount": 2,
"token": "abcd"
}
}
And if i press next again in the 3rd api call is should use the 2nd response token as param for the 3rd call and it will give some token and if user presses Prev then it should use that tocken and send as param here this i am unable to solve this in front end i wrote like
<mat-paginator [pageSize]="10" [length]="totalLength" [pageSizeOptions]="[5, 10, 25, 100]" (page)="PageEvents($event)"></mat-paginator>
PageEvents(event: PageEvent){
this.pageNumber = 1;
const pageSize = +event.pageSize;
const currentPage = +event.pageIndex + 1;
const pagination = {
searchQuery: '',
pageSize: pageSize,
token: ''
};
if(currentPage > this.pageNumber) {
console.log('next button',pageSize,currentPage)
} else {
console.log('prev button',pageSize,currentPage)
}
}
totalLength= 50
here my issues
