2016-02-27 85 views
0

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

任何形式的帮助将不胜感激。

+0

数据是否与你的ng-repeat一起显示? – Rarepuppers

+0

@comoss不,屏幕上没有任何事情发生。 – adolfosrs

回答

1

此处的投诉是Firebase.util未定义。最有可能的是,您未通过脚本标记包含库,或者您将错误的顺序包含在内,并且在代码被调用时它不可用。

问题中的代码没有提供mcve,并且该错误与此处显示的代码无关,因此在回答此问题时涉及到一些猜测。

+0

好的,还有什么会有所帮助的呢? “你错误地把事情包括在内”是什么意思?什么应该包括第一或最后? – adolfosrs

+0

如果您不知道'

相关问题