I have this component here:
import { Component } from '@angular/core';
@Component({
selector: 'component-a',
templateUrl: '../html/componenta.html'
})
export class ComponetA {
color_class:string = "red_bg";
}
My css for .red_bg is:
.red_bg{background-color:red}
Now, in my componenta.html, when I attach the class to a button using ngClass, it works perfect, here is the snippet <button [ngClass]="{'red_bg': 1===1}">Click</button>
My question is how do I use ngClass and get the value of the class name from the component? Here is what I tried but didn't work: <button [ngClass]="{color_class: 1===1}">Click</button>
I also tried interpolating this way <button [ngClass]="{'{{color_class}}': 1===1}">Click</button>
but still didn't work.
Thanks in advance