I recently started using angular material to build angular form in which i need to use angular material date picker but am not able to add any mask on the input element.
I want to allow the user only to be able to enter numbers and to format them in date format (MM/DD/YYYY) as he types in.
html:
<div class="example-container">
<mat-form-field appearance="outline" class="col-sm-12 col-md-6 col-lg-6 required margin-top-ten">
<mat-label>
<span class="title">Date of Birth (MM/DD/YYYY)</span>
</mat-label>
<input matInput [matDatepicker]="myDatepicker" formControlName="dateOfBirth" maxlength="10">
<mat-datepicker-toggle matSuffix [for]="myDatepicker"></mat-datepicker-toggle>
<mat-datepicker #myDatepicker></mat-datepicker>
</mat-form-field>
</div>
Note: I was trying to use ngx-mask and is not working on date picker only, on a regular text input like phone or fax fields is working just fine.