Skip to content

Instantly share code, notes, and snippets.

@katowulf
katowulf / filter_using_extend.js
Last active November 7, 2019 21:10
Filter records loaded into AngularFire based on some criteria.
// 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;
@katowulf
katowulf / app.js
Last active September 15, 2017 01:22
Simple infinite scroll example in AngularFire with Firebase.util (http://firebase.github.io/firebase-util/)
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