Marko
Marko

Reputation: 1401

Fill datetime-local input field

I want to set the value of a datetime-local input field in my component class but I cannot bind the value.

What I am missing?

HTML

<input id="date" type="datetime-local" [(ngModel)]="model.date" class="form-control" />

TS

public model: Model = new Model(-1, "old", new Date(2000, 1,1 ));

Here is a example Plunker.

The datetime-local input field has no value (Chrome 55) datetime-local has no value

Upvotes: 1

Views: 3256

Answers (1)

Dimanoid
Dimanoid

Reputation: 7289

I think you need to use string format for this.model.date, I changed your plunker and fill fields now works fine. https://plnkr.co/edit/FpEBvc?p=preview

Upvotes: 1

Related Questions