我正在使用与 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);
帖子.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>
任何形式的帮助将不胜感激。