This issue faced when using mat-datepicker inside *ngFor.
mat-datepicker requires a template reference variable #test in order to bind to the input.
Is there a direct way to take reference variables when using inside *ngFor, in general? I couldn't find a way.
Simple working example without *ngFor
<mat-form-field>
<input matInput [matDatepicker]="test" placeholder="Enter Date" [(ngModel)]="someDate" name="someDate">
<mat-datepicker-toggle matSuffix [for]="test"></mat-datepicker-toggle>
<mat-datepicker #test></mat-datepicker>
</mat-form-field>
But since template reference variables must be unique for the whole template, you can't directly use the mat-datepicker for scenario when the above block is repeated inside an *ngFor, test wouldn't be unique.
Any pointers will be helpful.