screen change event listeners javascript code example
Example 1: check window resize javascript
window.addEventListener("resize", () => {
// CODE
});
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)
})
}