A Pen by Rasmus Andersen on CodePen.
Created
June 19, 2014 09:18
-
-
Save four2theizz0/60bdc90d0e1d58b07954 to your computer and use it in GitHub Desktop.
A Pen by Rasmus Andersen.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html ng-app="ionicApp"> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> | |
<title>Ionic List Directive with infinite scrolling</title> | |
<link href="http://code.ionicframework.com/nightly/css/ionic.min.css" rel="stylesheet"> | |
<script src="http://code.ionicframework.com/nightly/js/ionic.bundle.min.js"></script> | |
</head> | |
<body ng-controller="MyCtrl"> | |
<header class="bar bar-header bar-positive"> | |
<h1 class="title">Ionic Infinite Scroll with {{items.length}} items</h1> | |
</header> | |
<ion-content class="has-header"> | |
<ion-list> | |
<ion-item ng-repeat="item in items" | |
item="item" | |
href="#/item/{{item.id}}"> | |
Item {{ item.id }} | |
</ion-item> | |
</ion-list> | |
<ion-infinite-scroll ng-if="!noMoreItemsAvailable" on-infinite="loadMore()" distance="20%"></ion-infinite-scroll> | |
</ion-content> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('ionicApp', ['ionic']) | |
.controller('MyCtrl', function($scope) { | |
$scope.noMoreItemsAvailable = false; | |
$scope.loadMore = function() { | |
$scope.items.push({ id: $scope.items.length}); | |
$scope.items.push({ id: $scope.items.length}); | |
$scope.items.push({ id: $scope.items.length}); | |
$scope.items.push({ id: $scope.items.length}); | |
$scope.items.push({ id: $scope.items.length}); | |
if ( $scope.items.length == 999 ) { | |
$scope.noMoreItemsAvailable = true; | |
} | |
$scope.$broadcast('scroll.infiniteScrollComplete'); | |
}; | |
$scope.items = []; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment