Issue
I have a ngFor loop and I want to assign a unique class to each element but I have an already existing ngClass condition.
<div class="b-game-card" *ngFor="let info of list" [ngClass]="{active: isActive(info)}">
<div class="b-game-card__cover"></div>
</div>
I tried adding [ngClass]="{active: isActive(info), info.name}"
but it didn't work for me.
Solution
Is info.name a class you want to apply? If so move it over to your class attribute instead:
<div
class="b-game-card {{ info.name }}"
*ngFor="let info of list"
[ngClass]="{active: isActive(info)}">
<div class="b-game-card__cover"></div>
</div>
Answered By - Mathew Berg
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.