I'm using angular materials mat-table
for displaying data.
Well, when you click on one cell, an input field is displaying and the span-tag hides.
But in my case, every cell in this row is displaying an input field as you can see on the screenshot:
My ngIf
-Statement looks as follows:
Shows span-tag: !editable || (selectedRowIdx !== idx)
Shows input-tag: editable && (selectedRowIdx == idx)
<ng-container matColumnDef="TYPE">
<mat-header-cell *matHeaderCellDef> TYPE </mat-header-cell>
<mat-cell *matCellDef="let elem; let idx = index" (click)="testFocusIn(elem.TYPE)">
<span *ngIf="!editable || (selectedRowIdx !== idx)">{{elem.TYPE}}</span>
<mat-form-field *ngIf="editable && (selectedRowIdx == idx)">
<input matInput [(ngModel)]="elem.TYPE" [appAutoFocus]="(focus === elem.TYPE)">
</mat-form-field>
</mat-cell>
</ng-container>
<ng-container matColumnDef="NAME">
<mat-header-cell *matHeaderCellDef> NAME </mat-header-cell>
<mat-cell *matCellDef="let elem; let idx = index" (click)="testFocusIn(elem.NAME)">
<span *ngIf="!editable || (selectedRowIdx !== idx)">{{elem.NAME}}</span>
<mat-form-field *ngIf="editable && (selectedRowIdx == idx)">
<input matInput [(ngModel)]="elem.NAME" [appAutoFocus]="(focus === elem.NAME)">
</mat-form-field>
</mat-cell>
</ng-container>
What else could I check? Maybe to define an ID-tag?