2

To get computed styles I need to get access to global variables, like:

window.getComputedStyle(el, null).getPropertyValue('font-size');

But in component I just have ElementRef object. How I can get current font-size of element?

Serhii Polishchuk
  • 1,442
  • 17
  • 22

1 Answers1

1

If you really need window object in component you should use dependency injectiton within your component your constructor.

And the ways of how you can do it depends on your version, same with that you can use ngZone on Angular 4+ to run some code outside angular app, so window will be there.

Here is common cases Angular2 - How to inject window into an angular2 service

Kraken
  • 1,905
  • 12
  • 22