I need to display dynamic color for a div based on some condition. I am getting console error.
I have tried
<div [ngClass]="{'clr-{{students.rollNo 1}}': students.active}"></div>
students is my array, i have a class called .clr-5, clr-6 etc... in css
CodePudding user response:
try this:
<div [ngClass]="[ students.active ? 'clr-' students.rollNo 1 : '']"></div>
class bindings are updated in Angular 9. Read more about it here
CodePudding user response:
string interpolation not work inside property binding. you should deal with that like:
<div [ngClass]="{`clr-${students.rollNo 1}`: students.active}"></div>