document.getElementById().setAttribute();

I did it as follows:

[class.yourVariable]="your_class_if_variable_is_true"

yourVariable is then manipulated to one’s heart content.

In my specific case I’ve got several control variables, but the idea is the same.