Declaration expected. 89 @HostListener('window:resize', ['$event']) this.getScreenSize(); code example

Example 1: typescript on window resize

@HostListener('window:resize', ['$event'])
onResize(event) {
  event.target.innerWidth;
}

Example 2: div resize event typescript

resizeObservable$: Observable<Event>
resizeSubscription$: Subscription

ngOnInit() {
    this.resizeObservable$ = fromEvent(window, 'resize')
    this.resizeSubscription$ = this.resizeObservable$.subscribe( evt => {
      console.log('event: ', evt)
    })
}