2015-07-03 75 views

回答

8

如果你只是想听滚动事件,最简单的方法可能是使用on-scroll指令。

HTML:

<ion-content on-scroll="getScrollPosition()"> 
    <div class="list"> 
     <div class="item" ng-repeat="item in data.items">Item {{item}}</div> 
    </div> 
</ion-content> 

JS:

$scope.getScrollPosition = function(){ 
    console.log($ionicScrollDelegate.getScrollPosition().top) 
} 

Codepen here

+1

出于某种原因,这个代码在我的应用程序工作。我想我有其他东西“阻止”它。我发现了一篇博文,它告诉我们使用on-refresh指令来调用一个广播scroll.refreshComplete事件(带有$ scope。$ broadcast('scroll.refreshComplete');)的函数,现在它可以工作。谢谢。 –

+0

不,根本不起作用。 – Romain

+0

这对离子1.3.x有效。 – skotturi