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?

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.