简体   繁体   中英

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}"

Change this:

isActive:true;
canToggle:false;

to this:

isActive = true;
canToggle = false;

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM