Skip to content

Commit

Permalink
Merge pull request #5 from sergei202/master
Browse files Browse the repository at this point in the history
Handle null values.
  • Loading branch information
JohannesHoppe authored Feb 23, 2017
2 parents ce4964f + 776c5a4 commit 6d5611d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions angular-date-value-accessor/src/date-value-accessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ export class DateValueAccessor implements ControlValueAccessor {
constructor(private _renderer: Renderer, private _elementRef: ElementRef) { }

writeValue(value: Date): void {
if (!value) {
this._renderer.setElementProperty(this._elementRef.nativeElement, 'value', null);
return;
}
this._renderer.setElementProperty(this._elementRef.nativeElement, 'valueAsDate', value);
}

Expand Down

0 comments on commit 6d5611d

Please sign in to comment.