Closed gmengi closed 4 years ago
Type value to the input box. It must be in the same format that is given in dateFormat option.
Try here: https://kekeh.github.io/angular-mydatepicker/
The first date picker on the page. Type value 10.7.2020 into input box and the open calendar. Date 10.7.2020 is selected on calendar.
Use ngModel to set default date like below.
<input class="input-box" angular-mydatepicker name="mydate" (click)="dp.toggleCalendar()"
[(ngModel)]="model" [options]="myDpOptions" #dp="angular-mydatepicker"
(dateChanged)="onDateChanged($event)"/>
this.model = {isRange: false, singleDate: {jsDate: new Date()}};
// or
this.model = {isRange: false, singleDate: {date: {year: 2020, month: 7, day: 10}}};
Examples:
What? if I'm using inline mode with input and bind value with ngModel?
Set input type to hidden like here: https://github.com/kekeh/angular-mydatepicker/blob/master/example/app/date-picker-inline/date-picker-inline.html#L10
On this https://kekeh.github.io/angular-mydatepicker/ page the inline datepicker uses input type of hidden.
In this case, I don't want to hide input. because I want to populate the selected date or default date in input as well.
After selecting the date from the date picker, it reflects the value in input but if I have a default value in input that is not reflecting into date picker.