Created
March 21, 2015 15:34
-
-
Save katowulf/c74b6e2d047c9e2eaaa9 to your computer and use it in GitHub Desktop.
Example of infinite scroll using ui-grid and Firebase (uses http://firebase.github.io/firebase-util/)
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
var app = angular.module('app', ['firebase', 'ui.grid', 'ui.grid.infiniteScroll']); | |
app.controller('ctrl', function($scope, $firebaseArray) { | |
var baseRef = new Firebase('https://fbutil.firebaseio.com/paginate'); | |
var scrollRef = new Firebase.util.Scroll(baseRef, 'number'); | |
//$scope.data = $firebaseArray(scrollRef); | |
$scope.opts = { | |
columnDefs: [ | |
{name: '$id', displayName: 'ID'}, | |
{name: 'string'}, | |
{name: 'number'}, | |
{name: 'timestamp', displayName: 'Date'}, | |
{name: '$priority', displayName: 'Priority'} | |
] | |
}; | |
$scope.opts.data = $firebaseArray(scrollRef); | |
scrollRef.scroll.next(25); | |
$scope.opts.onRegisterApi = function(gridApi){ | |
gridApi.infiniteScroll.on.needLoadMoreData($scope,function(){ | |
scrollRef.scroll.next(25); | |
}); | |
gridApi.infiniteScroll.on.needLoadMoreDataTop($scope,function(){ | |
scrollRef.scroll.prev(25); | |
}); | |
$scope.opts.data.$watch(function() { | |
$scope.$evalAsync(function() { | |
gridApi.infiniteScroll.dataLoaded(); | |
}); | |
}); | |
}; | |
}); |
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
<div ui-grid="opts" class="grid" ui-grid-infinite-scroll></div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment