我正在与Angular集成在一起,并试图在我的应用程序中实现无限滚动。ngInfiniteScroll导致TypeError:无法读取属性'Scroll'的undefined
所以我很努力地在我的页面中使用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一起显示? – Rarepuppers
@comoss不,屏幕上没有任何事情发生。 – adolfosrs