Reputation: 1508
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?
Upvotes: 2
Views: 2336
Reputation: 1955
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
Upvotes: 1