I have a function, which is returning me a background color from a json file list, getBackground(items). I am using one component which adds automaticly a class name upon each item click (its a list combo box component), it adds class .item-radio-checked. I want to find a way to set the background color via my function to this class, but I am not sure how, since this class is added only when user click over the item. I can use:
[style.background]="getBackground(items)"
but this applies to the background attribute of the item element, not to the class I want to trigger. Via css will not work, since its a static and I want the background color to be taken from my function. So it will be:
.item-radio-checked {
background-color: $colorname;
}
I know that i need to handle this via angular and over the DOM, not in the SCSS file, but I am not sure how.
I need to know each this is this class added to the item (has item been clicked) and apply the right dynamic color from my function to it
[style.background]="getBackground(items)"? If that the case, you can do something like this:[style.background]="conditionWhenClicked ? getBackground(items) : null"