forked from michaelbromley/ngx-pagination
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pagination-controls.component.ts
53 lines (49 loc) · 1.69 KB
/
pagination-controls.component.ts
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
41
42
43
44
45
46
47
48
49
50
51
52
53
import {Component, Input, Output, EventEmitter, ChangeDetectionStrategy, ViewEncapsulation} from '@angular/core'
import {DEFAULT_TEMPLATE, DEFAULT_STYLES} from './template';
function coerceToBoolean(input: string | boolean): boolean {
return !!input && input !== 'false';
}
/**
* The default pagination controls component. Actually just a default implementation of a custom template.
*/
@Component({
selector: 'pagination-controls',
template: DEFAULT_TEMPLATE,
styles: [DEFAULT_STYLES],
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None
})
export class PaginationControlsComponent {
@Input() id: string;
@Input() maxSize: number = 7;
@Input()
get directionLinks(): boolean {
return this._directionLinks;
}
set directionLinks(value: boolean) {
this._directionLinks = coerceToBoolean(value);
}
@Input()
get autoHide(): boolean {
return this._autoHide;
}
set autoHide(value: boolean) {
this._autoHide = coerceToBoolean(value);
}
@Input()
get responsive(): boolean {
return this._responsive;
}
set responsive(value: boolean) {
this._responsive = coerceToBoolean(value);
}
@Input() previousLabel: string = 'Previous';
@Input() nextLabel: string = 'Next';
@Input() screenReaderPaginationLabel: string = 'Pagination';
@Input() screenReaderPageLabel: string = 'page';
@Input() screenReaderCurrentLabel: string = `You're on page`;
@Output() pageChange: EventEmitter<number> = new EventEmitter<number>();
private _directionLinks: boolean = true;
private _autoHide: boolean = false;
private _responsive: boolean = false;
}