typescript window resize event type code example
Example 1: check window resize javascript
window.addEventListener("resize", () => {
});
Example 2: typescript on window resize
@HostListener('window:resize', ['$event'])
onResize(event) {
event.target.innerWidth;
}
Example 3: 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 4: 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>