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