forked from ng-bootstrap/ng-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
datepicker-config.ts
35 lines (28 loc) · 1.05 KB
/
datepicker-config.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
import {Component} from '@angular/core';
import {
NgbCalendar,
NgbDate,
NgbDateStruct,
NgbInputDatepickerConfig
} from '@ng-bootstrap/ng-bootstrap';
@Component({
selector: 'ngbd-datepicker-config',
templateUrl: './datepicker-config.html',
providers: [NgbInputDatepickerConfig] // add config to the component providers
})
export class NgbdDatepickerConfig {
model: NgbDateStruct;
constructor(config: NgbInputDatepickerConfig, calendar: NgbCalendar) {
// customize default values of datepickers used by this component tree
config.minDate = {year: 1900, month: 1, day: 1};
config.maxDate = {year: 2099, month: 12, day: 31};
// days that don't belong to current month are not visible
config.outsideDays = 'hidden';
// weekends are disabled
config.markDisabled = (date: NgbDate) => calendar.getWeekday(date) >= 6;
// setting datepicker popup to close only on click outside
config.autoClose = 'outside';
// setting datepicker popup to open above the input
config.placement = ['top-left', 'top-right'];
}
}