Skip to content
This repository has been archived by the owner on Oct 5, 2019. It is now read-only.

Keep field clean on Init #176

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ng2-datetime/ng2-datetime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class NKDatetime implements ControlValueAccessor, AfterViewInit, OnDestro
}

writeValue(value: any) {
this.date = value;
this.date = new Date(value);
if (isDate(this.date)) {
setTimeout(() => {
this.updateModel(this.date);
Expand Down Expand Up @@ -266,5 +266,5 @@ function uniqueId(prefix: string): string {
}

function isDate(obj: any) {
return Object.prototype.toString.call(obj) === '[object Date]';
return obj && obj.toString() !== 'Invalid Date';
}