I want to open a date picker when a user focuses on an input element. I don't want a toggle button.
<input
matInput
[matDatepicker]="picker"
type="text"
name="dob"
#dob="ngModel"
class="form-control"
[(ngModel)]="details.dob"
placeholder="Enter Date of Birth"
readonly
/>
<mat-datepicker #picker></mat-datepicker>
The above code does not provide this feature.
Add the focus event with the handler which is picker.open()
<input
matInput
[matDatepicker]="picker"
type="text"
name="dob"
#dob="ngModel"
class="form-control"
[(ngModel)]="details.dob"
(focus)="picker.open()"
placeholder="Enter Date of Birth"
readonly
/>
<mat-datepicker #picker></mat-datepicker>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With