0
I am trying to apply a class when my element is clicked, but it is within two *ngFor.
I thought to do with multidimensional array but apparently this is not the correct form because it is applying the class in several elements.
I tried something like:
<div *ngFor="let tabelaAnuncioContas of sortedData; let a = index">
<tr *ngFor="let anuncio of tabelaAnuncioContas.data[0].anuncio; let i = index">
<td><img [class.zoomImg]="zoomImg[a][i] == true" (click)="zoomImg[a][i]= !zoomImg[a][i]" [src]="anuncio.produto.foto_prin_1"></td>
</tr>
</div>
TS:
zoomImg:[][] = [[]];
When you have more than one element in the sorted array:
Cannot read Property '0' of Undefined
When you have only one element in the sorted Data array no error message is generated but when you click on the element all elements apply the class.
Check before iterating
*ngIf="!tabelaAnuncioContas.data[0]"
– renanvm
Cannot read Property 'data' of Undefined
– veroneseComS
do it only for the
!tabelaAnuncioContas
– renanvm
If I put <div *ngIf="! tableNew.data[0]"> element is not shown
– veroneseComS
Only the ! tableNew functions are not shown my listing.
– veroneseComS
What are the data composed by
SortedData
?– Victor Henrique