scroll event on Hostlistener

后端 未结 5 1383
一生所求
一生所求 2020-12-31 22:19

I have defined template

@Component({
    selector: \'name\',
    directives: [ ... ],
    templateUrl: \'name.html\'
})

and class



        
5条回答
  •  时光取名叫无心
    2020-12-31 22:51

    You could do it by the following code as well:

    import { HostListener} from "@angular/core";
    
    @HostListener("window:scroll", [])
    onWindowScroll() {
     //we'll do some stuff here when the window is scrolled
    }
    

提交回复
热议问题