Append children to document.body angular way

387 Views Asked by At

I have written code like below

this._renderer.appendChild(document.body, form);

This works fine. But i am directly accessing document.body. Is there a angular 2/4 way of access document.body?

1

There are 1 best solutions below

4
Suren Srapyan On BEST ANSWER

You can inject via DOCUMENT injection token. This will give you the document object in Angular way (as you have said).

constructor(@Inject(DOCUMENT) private document: Document)