blob: c242b7e72d1f903f756c67700f889504f17adb84 (
plain)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
|
import {Component, OnInit} from '@angular/core';
import {PackagesStore} from '../../packages.store';
@Component({
selector: 'app-package-pagination',
templateUrl: './package-pagination.component.html',
styleUrls: ['./package-pagination.component.css'],
})
export class PackagePaginationComponent implements OnInit {
pageNumber: number;
totalCount: number;
pageSize: number;
previousPage: number;
constructor(private packagesStore: PackagesStore) {
this.pageSize = packagesStore.pageSize;
this.packagesStore.state$
.subscribe(state => {
this.pageNumber = state.currentPage + 1;
this.totalCount = state.totalPackages;
});
}
ngOnInit() {
}
public getPageFromService(page) {
console.log('getPageFromService', page);
if (isNaN(page)) {
page = 1;
console.log('page change to first...', page);
}
if (this.previousPage !== page) {
this.packagesStore.getPage(page - 1, this.packagesStore.pageSize);
this.previousPage = page;
}
}
}
|