Angular 4 @HostListener Window scroll event strangely does not work in Firefox

前端 未结 4 1921
南笙
南笙 2020-12-06 02:16

I\'m using @HostListener(\'window:scroll\', []) in Angular 4 app in order to add additional class to the header on scrolling. It works fine in Chrome but I noti

4条回答
  •  误落风尘
    2020-12-06 03:03

    try this:

    @HostListener('window:scroll', ['$event'])
    onWindowScroll($event) {
        console.log("scrolling...");
    }
    

    I prefer this:

    this.eventSubscription = Observable.fromEvent(window, "scroll").subscribe(e => {
                    this.onWindowScroll();
                });
    

提交回复
热议问题