0

I can do this to get the window size on resizing

@HostListener('window:resize', ['$event']) resizeHandler(event: any) { this.isSmallScreen = event.target.innerWidth > 600; }

How can I get the window size on load

If the page loads when the screen size is > 600 I need isSmallScreen to true,

I still need the window on resize but I need the size when the page loads as well

1 Answer 1

2
ngOnInit() {
    this.isSmallScreen = (window.innerWidth) > 600;
}
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.