diff --git a/components/datepicker/datepicker-inner.component.ts b/components/datepicker/datepicker-inner.component.ts index dbd7062021..d5a9237ae9 100644 --- a/components/datepicker/datepicker-inner.component.ts +++ b/components/datepicker/datepicker-inner.component.ts @@ -1,4 +1,4 @@ -import {Component, OnInit, EventEmitter, Input, OnChanges} from '@angular/core'; +import {Component, OnInit, EventEmitter, Input, OnChanges, Output} from '@angular/core'; import {CORE_DIRECTIVES, NgClass} from '@angular/common'; import {FORM_DIRECTIVES, NgModel} from '@angular/forms'; import {DateFormatter} from './date-formatter'; @@ -70,6 +70,8 @@ export class DatePickerInnerComponent implements OnInit, OnChanges { @Input() public dateDisabled:any; @Input() public initDate:Date; + @Output() public selectionDone: EventEmitter = new EventEmitter(undefined); + public stepDay:any = {}; public stepMonth:any = {}; public stepYear:any = {}; @@ -248,6 +250,7 @@ export class DatePickerInnerComponent implements OnInit, OnChanges { } this.activeDate = new Date(date.getFullYear(), date.getMonth(), date.getDate()); + this.selectionDone.emit(this.activeDate); } else { this.activeDate = date; this.datepickerMode = this.modes[this.modes.indexOf(this.datepickerMode) - 1]; diff --git a/components/datepicker/datepicker.component.ts b/components/datepicker/datepicker.component.ts index a2deae7382..df495e45aa 100644 --- a/components/datepicker/datepicker.component.ts +++ b/components/datepicker/datepicker.component.ts @@ -1,4 +1,4 @@ -import {Component, Self, Input} from '@angular/core'; +import {Component, Self, Input, Output, EventEmitter} from '@angular/core'; import {CORE_DIRECTIVES} from '@angular/common'; import {FORM_DIRECTIVES, ControlValueAccessor, NgModel} from '@angular/forms'; import {DatePickerInnerComponent} from './datepicker-inner.component'; @@ -32,7 +32,8 @@ import {YearPickerComponent} from './yearpicker.component'; [dateDisabled]="dateDisabled" [templateUrl]="templateUrl" [onlyCurrentMonth]="onlyCurrentMonth" - [shortcutPropagation]="shortcutPropagation"> + [shortcutPropagation]="shortcutPropagation" + (selectionDone)="onSelectionDone($event)"> @@ -64,6 +65,8 @@ export class DatePickerComponent implements ControlValueAccessor { // todo: change type during implementation @Input() public dateDisabled:any; + @Output() public selectionDone: EventEmitter = new EventEmitter(undefined); + public onChange:any = Function.prototype; public onTouched:any = Function.prototype; @@ -91,6 +94,10 @@ export class DatePickerComponent implements ControlValueAccessor { this.cd.viewToModelUpdate(event); } + public onSelectionDone(event: Date): void { + this.selectionDone.emit(event); + } + // todo: support null value public writeValue(value:any):void { // todo: fix something sends here new date all the time