how to run resize event only on client side angular 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: how to run resize event only on client side angular
<div (window:resize)="onResize($event)"
Example 4: how to run resize event only on client side angular
@HostListener('window:resize', ['$event'])
onResize(event) {
if(window){
let a=window.innerWidth;
}
}