Skip to content

Commit

Permalink
fix date change value for internationalization
Browse files Browse the repository at this point in the history
  • Loading branch information
jwshinjwshin committed Sep 1, 2017
1 parent 1b6b270 commit 4016c96
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lib/datepicker/datepicker-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ export class MdDatepickerInput<D> implements AfterContentInit, ControlValueAcces
/** The value of the input. */
@Input()
get value(): D | null {
return this._getValidDateOrNull(this._dateAdapter.parse(
this._elementRef.nativeElement.value, this._dateFormats.parse.dateInput));
return this._value;
}
set value(value: D | null) {
if (value != null && !this._dateAdapter.isDateInstance(value)) {
Expand All @@ -123,12 +122,14 @@ export class MdDatepickerInput<D> implements AfterContentInit, ControlValueAcces
value = this._getValidDateOrNull(value);

let oldDate = this.value;
this._value = value;
this._renderer.setProperty(this._elementRef.nativeElement, 'value',
value ? this._dateAdapter.format(value, this._dateFormats.display.dateInput) : '');
if (!this._dateAdapter.sameDate(oldDate, value)) {
this._valueChange.emit(value);
}
}
private _value: D | null;

/** The minimum valid date. */
@Input()
Expand Down

0 comments on commit 4016c96

Please sign in to comment.