2
I’m trying to pass the index
of ngFor
within the ngClass
to activate the correct class. I have tried several ways, but could not.
Follows the code:
<td *ngFor="let cell of row; let i = index" [ngClass]="{'col-tb-1-active' : classFocus.col1 , 'col-tb-1' : !classFocus.col1}">{{ cell.value }}</td>
In this case, where there is "1" I want to exchange for index
. would be something like:
<td *ngFor="let cell of row; let i = index" [ngClass]="{'col-tb-i-active' : classFocus.coli , 'col-tb-i' : !classFocus.coli}">{{ cell.value }}</td>
I tried that way, but it didn’t work.
– Bruno
@Bruno see me example added the answer!
– Marconi
In the example it worked. However, there is no ngClass condition like the one I posted. I believe the problem is there. I’m not at work anymore, anything I can send a print of the bugs tomorrow. Thanks for the feedback and the layout!
– Bruno
@Bruno for nothing, my idea is to show you how to do, if there is some error in the code is difficult to identify because completely as is your system, understand?
– Marconi
I totally understand. By the example you posted, I tried to change it to [ngClass]="{'col-tb-' + i + '-active' i > 0 , 'col-tb-' + i : i < 0}" That way it would be more or less the way I needed it, but it didn’t work there either. Maybe you’re screwing up, I don’t know.
– Bruno