ng-mat-daterange-picker
Version:
[](https://circleci.com/gh/ashishgkwd/ngx-mat-daterange-picker) [](https
57 lines (48 loc) • 1.53 kB
text/typescript
import {
Component,
ViewChild,
Output,
Input,
EventEmitter,
ChangeDetectionStrategy,
OnChanges,
SimpleChanges
} from '@angular/core';
import { MatCalendar } from '@angular/material/datepicker';
import { ConfigStoreService } from '../services/config-store.service';
({
selector: 'calendar-wrapper',
templateUrl: './calendar-wrapper.component.html',
styleUrls: ['./calendar-wrapper.component.css'],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class CalendarWrapperComponent implements OnChanges {
(MatCalendar, {static: false})
matCalendar: MatCalendar<Date>;
()
readonly selectedDateChange: EventEmitter<Date> = new EventEmitter<Date>();
dateFormat: string;
() selectedDate: Date;
() prefixLabel: string;
() minDate: Date;
() maxDate: Date;
weekendFilter = (d: Date) => true;
constructor(private configStore: ConfigStoreService) {
this.dateFormat = configStore.ngxDrpOptions.format;
if (configStore.ngxDrpOptions.excludeWeekends) {
this.weekendFilter = (d: Date): boolean => {
const day = d.getDay();
return day !== 0 && day !== 6;
};
}
}
ngOnChanges(changes: SimpleChanges) {
// Necessary to force view refresh
this.matCalendar.activeDate = changes.selectedDate.currentValue;
}
onSelectedChange(date) {
this.selectedDateChange.emit(date);
}
onYearSelected(e) {}
onUserSelection(e) {}
}