In an Angular application let's suppose we have a body element as
<body>
...
</body>
and now I want to set its background to some value using Angular Renderer2 as
this.renderer.setStyle(document.body, 'background', 'url("some-example-url");');
and nothing happens.
But now if I do it using setAttribute function as
this.renderer.setAttribute(document.body, 'style', 'background: url("some-example-url");');
this will work out fine.
My question is: can setStyle function operate on an element where the style attribute is not yet defined ?