blob: 43dc20b34e09eb4618e17e43708baf2e34f276e5 (
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
}
}
|