Your code is listening to the window object, so you can only get the window innerHeight and innerWidth. There are 2 solutions to get the current window height.
Get the Window Sizes
Angular window resize event
Eventbinding:
<div (window:resize)="onResizeHandler($event)">...</div>
public onResizeHandler(event): void {
event.target.innerWidth;
event.target.innerHeight;
}
Host Listener Decorator: (The much cleaner approach!)
@HostListener('window:resize', ['$event'])
onResizeHandler(event: Event): void {
event.target.innerWidth;
event.target.innerHeight;
}
Component Sizes:
There are some ways to get the component size but this is a really inefficient solution!!!!! Be careful while using this. The underlying NativeElement Api will directly access the DOM!
https://angular.io/api/core/ElementRef
EDIT:
To be clear, reading the element with this solution will be fine.
If you need to manipulate your element be sure to use Renderer2
https://angular.io/api/core/Renderer2
// Inject a element reference into your component constuctor
...
constructor(private elementRef: ElementRef) {...}
// implement a listener on window:resize and attach the resize handler to it
public onResizeHandler(): void {
this.elementRef.nativeElement.offsetHeight
this.elementRef.nativeElement.offsetWidth
}
If you only want to change styling on resize events
Be sure to use @media Queries in your css/scss.
This will be the best way to do so!