【发布时间】:2016-02-27 22:21:29
【问题描述】:
我正在使用与 Firebase 集成的 Angular,我正在尝试在我的应用程序中实现无限滚动。
所以我很难在我的页面中使用ngInfiniteScroll。关注this documentation 我开始面临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>
我们将不胜感激。
【问题讨论】:
-
数据是否与您的 ng-repeat 一起显示?
-
@comoss 不,屏幕上什么也没有发生。
标签: angularjs firebase angularfire nginfinitescroll