0

Firebase と統合された Angular を使用しており、アプリケーションで無限スクロールを実現しようとしています。

そのため、ページでngInfiniteScrollを使用するのに苦労しています。このドキュメントに従って、TypeError: Cannot read property 'Scroll' of undefined angular.js:13236エラーメッセージに直面し始めます。

(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>

あらゆる種類の助けをいただければ幸いです。

4

1 に答える 1