Skip to content

Commit

Permalink
fix(datepicker): added ngOnChanges hook
Browse files Browse the repository at this point in the history
closes #543
  • Loading branch information
erashu212 authored and valorkin committed May 26, 2016
1 parent 1470892 commit ecffdb0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions components/datepicker/datepicker-inner.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component, OnInit, EventEmitter, Input} from '@angular/core';
import {Component, OnInit, EventEmitter, Input, OnChanges} from '@angular/core';
import {
CORE_DIRECTIVES, FORM_DIRECTIVES, NgClass, NgModel
} from '@angular/common';
Expand Down Expand Up @@ -48,7 +48,7 @@ const SHORTCUT_PROPAGATION = false;
`,
directives: [FORM_DIRECTIVES, CORE_DIRECTIVES, NgClass, NgModel]
})
export class DatePickerInnerComponent implements OnInit {
export class DatePickerInnerComponent implements OnInit, OnChanges {
@Input() public datepickerMode:string;
@Input() public startingDay:number;
@Input() public yearRange:number;
Expand Down Expand Up @@ -97,7 +97,6 @@ export class DatePickerInnerComponent implements OnInit {

public set activeDate(value:Date) {
this._activeDate = value;
this.refreshView();
}

// todo: add formatter value to Date object
Expand Down Expand Up @@ -131,7 +130,10 @@ export class DatePickerInnerComponent implements OnInit {
} else if (this.activeDate === undefined) {
this.activeDate = new Date();
}
}

// this.refreshView should be called here to reflect the changes on the fly
public ngOnChanges():void {
this.refreshView();
}

Expand Down

0 comments on commit ecffdb0

Please sign in to comment.