I have a table like
<ng-container matColumnDef="position">
<mat-header-cell *matHeaderCellDef> No. </mat-header-cell>
<mat-cell *matCellDef="let row">
{{row.position}}
</mat-cell>
But I want something like. If you click on the cell, the cell will become an input field only for that row.
<ng-container matColumnDef="position">
<mat-header-cell *matHeaderCellDef> No. </mat-header-cell>
<mat-cell *matCellDef="let row" (click)="flag = true">
<ng-container
*ngIf="flag ? clicked : notClicked">
</ng-container>
<ng-template #notClicked>
<div>
{{row.position}}
</div>
</ng-template>
<ng-template #clicked>
<div>
<input matInput placeholder="Favorite food" value="{{row.position}}">
</div>
</ng-template>
</mat-cell>
How can I do it?
Note: I want to avoid writing a logic in the *.ts
file.