# Hostlistener not working in an inner component

I want to detect screen size changes from a component deep in the code.
The problem is that I cannot make the Hostlistener work.
When I use the same code in the app.component (the highest one in the hierarchy) everything works as expected.

@HostListener('window:resize', ['\$event'])
onResize(event) {
this.screenWidth = window.innerWidth;
}


The code above works when used in the outermost component but not in the innermost component.

Source: New feed
Source Url Hostlistener not working in an inner component