我正在與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