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']); | |
app.controller('ctrl', function($scope) { | |
var ref = new Firebase('https://fbutil.firebaseio.com/paginate'); | |
$scope.scrollItems = $scrollArray(ref, 'number'); | |
}); | |
app.factory('$scrollArray', function($firebaseArray) { | |
return function(ref, field) { | |
// create a special scroll ref |
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
// this will be much more efficient than $watch() | |
app.factory('FilteredArray', function($firebaseArray) { | |
function FilteredArray(ref, filterFn) { | |
this.filterFn = filterFn; | |
return $firebaseArray.call(this, ref); | |
} | |
FilteredArray.prototype.$$added = function(snap) { | |
var rec = $firebaseArray.prototype.$$added.call(this, snap); | |
if( !this.filterFn || this.filterFn(rec) ) { | |
return rec; |