When a record is clicked in my code, the details are displayed. Within this details section, there are 2 links (previous, next) that allow navigation to the previous and next records. The issue arises when navigating to the next page from pagination – upon clicking on previous or next, it continues to reference the first page's row index instead of the selected row.
To see the problem in action, please visit:
nextRecord() {
let next = (this.currentIndex += 1);
if (next > this.allUserTableData.length - 1) {
this.currentIndex = 1;
return;
}
let nextRecord = this.allUserTableData[next];
this.userObj = nextRecord;
console.log(nextRecord, next);
}
previousRecord() {
let next = (this.currentIndex -= 1);
if (next < 0) {
this.currentIndex = 0;
return;
}
let nextRecord = this.allUserTableData[next];
this.userObj = nextRecord;
console.log(nextRecord, next);
}
<button (click)="previousRecord()">Previous</button> | <button (click)="nextRecord()">Next</button>