Skip to content

wangdahoo/ngScroll

Repository files navigation

Angular Scroll Component version

smooth scrolling, pull to refresh and infinite loading, for Angular 1.x

Demo

see sample code in folder /demo. And checkout demo here

Quick Start

  <scroll on-refresh="onRefresh"
          on-infinite="onInfinite"
          delegate-id="'myScroller'">
    <!-- content in scroller -->      
    <div class="item" ng-repeat="it in items">
      <span ng-bind="it"></span>
    </div>
  </scroll>
// code in controller ... 

  $scope.$watch('items', function (newVal, oldVal) {
    $scope.$broadcast('$finishPullToRefresh');
    var scroller = $scroller.get('myScroller');
    if (scroller) scroller.resize();
  });
  
  $scope.onRefresh = function () {
    $timeout(function () {
      // do change items
    }, 2000);
  };
  
  $scope.onInfinite = function () {
    $timeout(function () {
      // do change items
    }, 2000);
  };

// code in controller ...