Search code examples
angularform-fields

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


Solution

  • 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