Managing pagination in my Angular application has been a smooth process with the function I have implemented. It involves subscribing to URL parameters and then using the router to navigate based on those parameters, including the page number passed as a value. One parameter indicates whether the filter is active, while the other holds the filter value(s).
Here is the original implementation:
public paginate(page) {
this.route.params.subscribe(
(params: any) => {
this.pn_location_e = params['pn_location_e'];
this.pn_location_v = params['pn_location_v'];
}
);
this.router.navigate(
['/clients', {
page: page,
pn_location_e: this.pn_location_e,
pn_location_v: this.pn_location_v,
}]);
let fn = resRecordsData => {
this.records = resRecordsData;
let data = resRecordsData.data;
};
this.dataService.filterByInput(
page - 1, this.pagesize, this.location, fn);
}
Everything was functioning smoothly following this setup.
However, a recent change by a colleague switched the filter syntax from "_" to ".". So, the line changed from:
this.pn_location_e = params['pn_location_e'];
to:
this.pn_location.e = params['pn_location.e'];
The challenge now is that initializing the variable with this new syntax in my Angular component results in a syntax error. Attempting pn_location.e
throws an error, and even trying pn_location['.e']
does not work either.
Is there a workaround for this issue, or should we revert back to using the underscore syntax for our filter parameters?