UNPKG

ng-mat-daterange-picker

Version:

[![CircleCI](https://circleci.com/gh/ashishgkwd/ngx-mat-daterange-picker.svg?style=shield)](https://circleci.com/gh/ashishgkwd/ngx-mat-daterange-picker) [![Maintainability](https://api.codeclimate.com/v1/badges/2b0d09a866f6d2ed139c/maintainability)](https

57 lines (48 loc) 1.53 kB
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'; @Component({ selector: 'calendar-wrapper', templateUrl: './calendar-wrapper.component.html', styleUrls: ['./calendar-wrapper.component.css'], changeDetection: ChangeDetectionStrategy.OnPush }) export class CalendarWrapperComponent implements OnChanges { @ViewChild(MatCalendar, {static: false}) matCalendar: MatCalendar<Date>; @Output() readonly selectedDateChange: EventEmitter<Date> = new EventEmitter<Date>(); dateFormat: string; @Input() selectedDate: Date; @Input() prefixLabel: string; @Input() minDate: Date; @Input() 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) {} }