I'm trying to convert Vanilla JavaScript code to Angular 2+.
In Javascript, I have a statement like this:
document.documentElement.style.setProperty(`--${cssVariableName}`, value);
In Angular, the only way I've found to replicate the above statement is like this:
renderer.setProperty(document.documentElement, 'style', `--${cssVariableName}: ${value}`);
The issue: If I have multiple custom properties being dynamically set at different times (--cssVariable1, --cssVariable2...). The Angular Renderer will overwrite the style property instead of appending to the style property.
Can the renderer be used to achieve this functionality? If not, is there a preferred way of using CSS custom properties in Angular? Thanks!