Authored by jinhu.tung

paginate with params

... ... @@ -35,7 +35,8 @@ const index = (req, res) => {
paginationOpts: {
page: pageNum, // current page: http://host/?page=2
limit: 10, // per_page records' number
total: 100 // total page number
total: 100, // total page number
queryParams: req.query
},
goods: {
img: 'http://placehold.it/274x366',
... ...
... ... @@ -78,11 +78,12 @@ exports.createPagination = function(pagination, options) {
queryParams += key + '=' + pagination.queryParams[key] + '&';
}
}
lastCharacterOfQueryParams = queryParams.substring(queryParams.length, -1);
//lastCharacterOfQueryParams = queryParams.substring(queryParams.length, -1);
lastCharacterOfQueryParams = queryParams.slice(queryParams.length - 1);
if (lastCharacterOfQueryParams === '&') {
// trim off last & character
queryParams = queryParams.substring(0, queryParams.length - 1);
queryParams = queryParams.slice(0, queryParams.length - 1);
}
}
... ...