googlearchive / firebase-util

An experimental toolset for Firebase
http://firebase.github.io/firebase-util
MIT License
276 stars 67 forks source link

TypeError: Cannot read property 'Scroll' of undefined #87

Closed adolfosrs closed 8 years ago

adolfosrs commented 8 years ago

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.

puf commented 8 years ago

Also posted on StackOverflow: http://stackoverflow.com/questions/35665313/nginfinitescroll-resulting-in-typeerror-cannot-read-property-scroll-of-undefi

On Sat, Feb 27, 2016 at 2:18 PM Adolfo Schneider notifications@github.com wrote:

I'm working with Angular integrated to 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 http://firebase.github.io/firebase-util/#/toolbox/Paginate/example/ngInfiniteScroll I starting 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

{{item.$id}}: {{item.number}}, {{item.string}}

Any kind of help will be appreciated.

— Reply to this email directly or view it on GitHub https://github.com/firebase/firebase-util/issues/87.

adolfosrs commented 8 years ago

@puf Is it a problem? Just making sure the community is aware of this.

katowulf commented 8 years ago

The problem comes when we duplicate energy and time answering the same question that someone else is answering in another channel. Thus, it's respectful of the community's time to note if you cross post.

adolfosrs commented 8 years ago

Ok, srry for that. Lets continue it in stackoverflow. Thanks