How angular material 2 date picker can be configured to be opened automatically on focus? I didn't find anything in the documentation at https://material.angular.io/components/datepicker/overview.
Current html is like this:
<input [mdDatepicker]="myDatepicker" id="inputWeekEnding" name="inputWeekEnding" type="text" class="form-control" show-button-bar="false"
[(ngModel)]="weekEnding" [mdDatepickerFilter]="weekEndingPickerFilter" (ngModelChange)="weekEndingChanged()"
required>
<span class="input-group-btn">
<button type="button" class="btn btn-default" [mdDatepickerToggle]="myDatepicker">
<i class="glyphicon glyphicon-calendar"></i>
</button>
</span>
<md-datepicker #myDatepicker md-open-on-focus ></md-datepicker>
Best Answer
mdDatepicker
provides methodopen()
in order to open it manually doe developers. You can invoke it atmd-input
's focus event. See docs(Method of MatDatepicker).Demo(included demo for opening on focus and opening in typescript)