TypeScript на Window
@HostListener('window:resize', ['$event'])
onResize(event) {
event.target.innerWidth;
}
Precious Polecat
@HostListener('window:resize', ['$event'])
onResize(event) {
event.target.innerWidth;
}
<div (window:resize)="onResize($event)"
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;
}
}