scroll event on Hostlistener

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

I have defined template

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

and class



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

    Assuming you want to display the host scroll (and not the windows one) and that you are using angular +2.1

      @HostListener('scroll', ['$event']) private onScroll($event:Event):void {
        console.log($event.srcElement.scrollLeft, $event.srcElement.scrollTop);
      };
    

提交回复
热议问题