when I am resizing a window. below event is not detecting window resize instead of this error I get each time
@HostListener('window:resize', ['$event'])
onResize(event) {
this.innerWidth = window.innerWidth;
}
Error :
GuidanceReportComponent_Host.ngfactory.js? [sm]:1 ERROR TypeError: jit_nodeValue_2(...).grElementList is not a function
at Object.eval [as handleEvent] (GuidanceReportComponent_Host.ngfactory.js? [sm]:1)
at handleEvent (core.js:23107)
at callWithDebugContext (core.js:24177)
at Object.debugHandleEvent [as handleEvent] (core.js:23904)
at dispatchEvent (core.js:20556)
at core.js:21003
at platform-browser.js:993
at ZoneDelegate../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
at Object.onInvokeTask (core.js:17290)
at ZoneDelegate../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:422)
By using the Host Listener Decorator, you are specifying Angular to listen to the window resize event which you are passing as an argument ($event). When you write the event Handler onResize(event) you actually pass the event recorded by angular. Hence the code is throwing you an error. The Below Code should work well.
@HostListener('window:resize', ['$event'])
onResize(event)
{
this.innerWidth = event.target.innerWidth;
}