I have a Pagination class that includes a method for local pagination.
export class Pagination {
public localPagination(type: IPaginationLocal): void {
this.paginationType = type;
this.fetchData();
}
public fetchData() {
this.paginationType.data = this.paginationType.data.slice(this.from, this.to);
}
}
In action:
this.plans = [1,2,3,4,5,6,7,8,9,10];
this.pagination.localPagination({
data: this.plans,
type: modePagination.LOCAL
});
console.log(this.plans);// It must be sliced
By passing the variable this.plans
to the
this.pagination.localPagination()
method,
The class slices the input data within the fetchData()
method.
After pagination is executed, I check:
console.log(this.plans);
Instead of returning the sliced array, it still returns the initial array this.plans
.