Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular setting default value of HTML datepicker

The [(ngModel)] is not setting default value for date picker. I have tried various different ways to populate the date picker but have been unable to.

My HTML

<input id="START_DATE" type="datetime-local" [(ngModel)]="startDate"/>

In that example the binding works but I am unable to set the default value.

I can set the value if i just interpolate the value but then i lose my 2 way binding. value="{{startDate}}"

like image 668
codyj110 Avatar asked Jul 16 '26 06:07

codyj110


1 Answers

Plunker - https://plnkr.co/edit/s5OMg2olU2yHI246nJOG?p=preview

<input type="date" [ngModel] ="dt | date:'yyyy-MM-dd'" (ngModelChange)="dt = $event">
like image 121
Younis Ar M Avatar answered Jul 17 '26 20:07

Younis Ar M



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!