在离子3中捕捉滚动事件是不可能的

时间:2018-02-18 22:15:10

标签: javascript angular ionic-framework ionic2 ionic3

我想在ionic3中捕获list组件的滚动事件,如下例所示:

<ion-content on-scroll = "scrolling()" on-scroll-complete = "scrollComplete()">
  <ion-list>
    <ion-item ng-repeat="item in items" 
              item="item"
              href="#/item/{{item.id}}">
      Item {{ item.id }}
    </ion-item>
  </ion-list>   
</ion-content>      

https://codepen.io/etipirev/pen/aNYNpy?editors=1111

因为它似乎在离子1中起作用,但在离子3中起作用?我还没有在离子文档中找到任何事件描述。是否有可能在离子3中捕捉列表项的滚动?

1 个答案:

答案 0 :(得分:4)

Ionic2 / 3的语法不同。这是它应该如何:

<ion-content (ionScroll)="scrolling($event)" (ionScrollEnd)="scrollComplete($event)">
  <ion-list>
   ...
  </ion-list>   
</ion-content> 

然后在你的ts文件中

constructor(){}
  scrolling(event) {
    // your content here for scrolling
  }

  scrollComplete(event) {
    // your content here of scroll is finished
  }
}