Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mat-datepicker add touchUI condition

I have an ionic application in which I use Angular's mat-datepicker. I want for the web version to get the normal date-picker and on the mobile devices to get the touchUi version. I tried putting *ngIf for the mat-date-picker selector but I start getting 'Cannot read property open of undefined'

       <mat-form-field class="day-datepicker">
           <input [(ngModel)]="FilterOptions.CreatedTo" disabled matInput [matDatepicker]="picker4">

            <mat-datepicker #picker4 *ngIf="_AppConfig.IsCordova" touchUi="true" disabled="false">
            </mat-datepicker>

            <mat-datepicker #picker4 *ngIf="!_AppConfig.IsCordova" disabled="false">
            </mat-datepicker>

        </mat-form-field>
like image 364
Missak Boyajian Avatar asked Nov 19 '25 20:11

Missak Boyajian


1 Answers

You need to change your code like below.

<mat-form-field class="day-datepicker">
    <input [(ngModel)]="FilterOptions.CreatedTo" disabled matInput [matDatepicker]="picker4">
    <mat-datepicker-toggle matSuffix [for]="picker4"></mat-datepicker-toggle>
    <mat-datepicker #picker4 [touchUi]="_AppConfig.IsCordova" disabled="false"></mat-datepicker>
</mat-form-field>`
like image 155
Dhara Gadhiya Avatar answered Nov 22 '25 16:11

Dhara Gadhiya



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!