typescript on window resize 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)
    })
}

Example 3: js windowresize event

<p>Resize the browser window to fire the <code>resize</code> event.</p>
<p>Window height: <span id="height"></span></p>
<p>Window width: <span id="width"></span></p>