projects/angular-calendar/src/modules/common/calendar-today/calendar-today.directive.ts
Change the view date to the current day. For example:
<button
mwlCalendarToday
[(viewDate)]="viewDate">
Today
</button>
Selector | [mwlCalendarToday] |
Inputs |
Outputs |
HostListeners |
constructor(dateAdapter: DateAdapter)
|
||||||
Parameters :
|
viewDate | |
Type : Date
|
|
The current view date |
viewDateChange | |
Type : EventEmitter<Date>
|
|
Called when the view date is changed |
click |
|
import {
Directive,
HostListener,
Input,
Output,
EventEmitter,
} from '@angular/core';
import { DateAdapter } from '../../../date-adapters/date-adapter';
/**
* Change the view date to the current day. For example:
*
* ```typescript
* <button
* mwlCalendarToday
* [(viewDate)]="viewDate">
* Today
* </button>
* ```
*/
@Directive({
selector: '[mwlCalendarToday]',
})
export class CalendarTodayDirective {
/**
* The current view date
*/
@Input() viewDate: Date;
/**
* Called when the view date is changed
*/
@Output() viewDateChange: EventEmitter<Date> = new EventEmitter();
constructor(private dateAdapter: DateAdapter) {}
/**
* @hidden
*/
@HostListener('click')
onClick(): void {
this.viewDateChange.emit(this.dateAdapter.startOfDay(new Date()));
}
}