0

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?

Hacker
  • 7,798
  • 19
  • 84
  • 154

1 Answers1

2

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) 
Suren Srapyan
  • 66,568
  • 14
  • 114
  • 112