0

I'm working with Angular integrated with Firebase and I'm trying to achieve a infinite scrolling in my application.

So I'm struggling to use the ngInfiniteScroll in my page. Following this documentation I start facing TypeError: Cannot read property 'Scroll' of undefined angular.js:13236 error message.

(function (angular) {
  "use strict";

  var app = angular.module('myApp.baby', ['firebase', 'firebase.utils', 'firebase.auth', 'ngRoute', 'infinite-scroll']);

  app.config(['$routeProvider', function($routeProvider) {
    $routeProvider.when('/:babyId', {
        templateUrl: 'baby/baby.html',
        controller: 'BabyController',
    });
  }]);

  app.controller('BabyController', ['$scope', 'Auth', 'fbutil', 'FBURL', '$location', '$firebaseObject', '$routeParams', '$firebaseArray',
    function($scope, Auth, fbutil, FBURL, $location, $firebaseObject, $routeParams, $firebaseArray) {
      $scope.FBURL = FBURL;

      var unbind;

      var baby = $firebaseObject(fbutil.ref('babies', $routeParams.babyId));
      baby.$bindTo($scope, 'baby').then(function(ub) { unbind = ub; });

      var baseRef = new Firebase(FBURL).child("posts");
      var scrollRef = new Firebase.util.Scroll(baseRef, 'number');
      $scope.items = $firebaseArray(scrollRef);
      $scope.items.scroll = scrollRef.scroll;
    }
  ]);

})(angular);

posts.html

<div infinite-scroll="items.scroll.next(10)" infinite-scroll-distance="1">
  <div ng-repeat="item in items">
    {{item.$id}}: {{item.number}}, {{item.string}}
  </div>
</div>

Any kind of help will be appreciated.

adolfosrs
  • 8,626
  • 5
  • 36
  • 65

1 Answers1

2

The complaint here is that Firebase.util is undefined. Most likely, you've failed to include the library via a script tag or you've included things in the wrong order and it's not available at the time your code is invoked.

The code in the question doesn't provide an mcve, and the error has nothing to do with the code presented here, so there is some guesswork involved in answering this.

Community
  • 1
  • 1
Kato
  • 38,684
  • 6
  • 110
  • 135
  • Ok, and what else would be helpful to be included here? And what do you mean by `included things in wrong order`? What should be included first or last? – adolfosrs Feb 27 '16 at 14:24
  • I'm not going to be much help here if you don't know what ` – Kato Feb 27 '16 at 14:55