【问题标题】:window:scroll not work with ngx-bootstrap modalwindow:scroll 不适用于 ngx-bootstrap 模式
【发布时间】:2019-02-09 10:13:39
【问题描述】:

我将ngx-bootrap 用于我的 Angular 5 应用程序。现在我想在滚动页面时监听事件,我使用@HostListener('window:scroll', []),但它不适用于打开模式。

那我该怎么办

export class ScrollDirective {
    @HostListener("window:scroll", []) onWindowScroll() {
       console.log(1)
    }
}

【问题讨论】:

    标签: angular ngx-bootstrap


    【解决方案1】:

    这适用于 ngx-bootstrap 模式

     ngOnInit() {
     Observable.fromEvent(this.el.nativeElement, 'scroll').subscribe((e: any) => {
         console.log(e.target);
      });
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-04-16
      • 2019-04-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-27
      • 1970-01-01
      • 2021-07-26
      相关资源
      最近更新 更多