I have an element to which I want to apply a specific class, so I used the [class.active] condition, which observes the changes of the Observable. But when I switch it, this does not apply to the following li and crashes the whole application:
<li *ngFor="let room of activeRooms$ | async" [class.active]="room.name === (currentRoomName$ | async)">
I found that if I use [ngClass] instead, it works fine:
<li *ngFor="let room of activeRooms$ | async" [ngClass]="{ active: room.name === (currentRoomName$ | async)}">
Why? Can anyone shed some light on this?
Thanks!
source share