I am using mat-datepicker under mat-table and want to set and change the values dynamically when I load the table.
here is my code:
HTML:
<ng-container matColumnDef="auctionDate">
<th mat-header-cell *matHeaderCellDef>Auction Date</th>
<td mat-cell *matCellDef="let row">
<input [formControl]="auctionDate" matInput [matDatepicker]="Appointmentpicker" [min]="today" readonly>
<mat-datepicker-toggle matSuffix [for]="Appointmentpicker"></mat-datepicker-toggle>
<mat-datepicker #Appointmentpicker></mat-datepicker>
</td>
</ng-container>
ts:
auctionDate = new FormControl();
this.data.items = [
{
"id": "65a03ce73b8226287003f3b4",
"subscriberId": "6331733aa38f414a418ab3fc",
"locationId": "63317704a38f414a418ab407",
"unitNo": "15151",
"customerTransactionId": "RB2SZ3VF",
"auctionDate": "04/04/2023",
"auctionLocation": "Location 1212",
"address": "12340 Boggy Creek ",
"businessNumber": "555544444444"
},
{
"id": "65a03ce73b8226287003f3b4",
"subscriberId": "6331733aa38f414a418ab3fc",
"locationId": "63317704a38f414a418ab407",
"unitNo": "15151",
"customerTransactionId": "RB2SZ3VF",
"auctionDate": "05/04/2023",
"auctionLocation": "Location 1212",
"address": "12340 Boggy Creek ",
"businessNumber": "555544444444"
}
];

If you have several dates, you need several variables, that's:
Or An array of variables and use
[(ngModel)]Or an array of FormControls and use
[FormControl]Or a FormArray