export class Component {
constructor(
private _http: HttpClient,
private _elementRef: ElementRef
) {}
ngOnInit() {
const json = '{"--background-color": "black", "--text-color": "red"}';
this._http.get('host')._subscribe(_res => {
for (let [key, value] of Object.entries(
JSON.parse(json)
)) {
this._elementRef.nativeElement.style.setProperty(
key,
value
);
console.log({ key, value });
}
});
}
}