how to run resize event only on client side angular

JavaScript
@HostListener('window:resize', ['$event'])
onResize(event) {
  event.target.innerWidth;
}
resizeObservable$: Observable<Event>
resizeSubscription$: Subscription

ngOnInit() {
    this.resizeObservable$ = fromEvent(window, 'resize')
    this.resizeSubscription$ = this.resizeObservable$.subscribe( evt => {
      console.log('event: ', evt)
    })
}@HostListener('window:resize', ['$event'])
onResize(event) {
  if(window){
      let a=window.innerWidth;
  }
}
<div (window:resize)="onResize($event)"

Source

Also in JavaScript: