Closed Redigast13 closed 8 years ago
This happens because of the following.
Although you see the error, there must be no difference in functionality
To silent the error, please assign an initialize your dateValue
with an empty string.
let dateNgModel: Date | String = this.ngModel;
if (!(this.ngModel instanceof Date || typeof this.ngModel === 'string')) {
console.error("datetime-picker directive requires ngModel");
this.ngModel = this.dateTime.formatDate(new Date(), this.dateOnly);
}
thank you!
I would nonetheless reopen the issue, because I would expect the plugin to support formControl / formControlName without needing ngModel. This "hacks" is indeed working, but that's not a proper solution I would say.
Here is my code:
<input type="text" class="form-control" placeholder="{{'FIELD_DATE' | translate}}" [formControl]="date" [ngModel]="dateValue" datetime-picker [date-format]="dateFormat">
I fetchdateValue
from server and in first time this variable is empty. I have the error in console: datetime-picker directive requires ngModel