Sandy Pm
Sandy Pm

Reputation: 43

angular ngClass directive not getting applied

Can some please help not sure why ngClass is not getting applied in this code

[ngClass]="{'active': isActive,'can-toggle':canToggle}"

Upvotes: 0

Views: 44

Answers (2)

Barremian
Barremian

Reputation: 31125

The member variables isActive and canToggle are wrongfully defined as types true and false. It should actually be assigned the booleans instead

isActive = true;
canToggle = false;

Modified Stackblitz.

Upvotes: 1

Gérôme Grignon
Gérôme Grignon

Reputation: 4228

Change this :

isActive:true;
canToggle:false;

to this :

isActive = true;
canToggle = false;

Upvotes: 1

Related Questions