blob: 16b47e9574d771d2b55dc7dee89033f24582bcb7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
import { Injectable } from '@angular/core';
import { URLSearchParams } from '@angular/http';
import { RestPagination } from './rest-pagination';
@Injectable()
export class RestService {
buildRestGetParams(pagination?: RestPagination, sort?: string) {
const params = new URLSearchParams();
if (pagination) {
const start: number = (pagination.currentPage - 1) * pagination.itemsPerPage;
const count: number = pagination.itemsPerPage;
params.set('start', start.toString());
params.set('count', count.toString());
}
if (sort) {
params.set('sort', sort);
}
return params;
}
}
|