AngularJS ng-infinite-scroll不能处理特定的容器/ div

时间:2015-07-14 07:34:34

标签: javascript angularjs nginfinitescroll

我在阅读了关于ng-infinite-scroll

的多篇帖子后写了这段代码
<div class="course-enrollment-friends" ng-class="{'friends-paginated':showMoreFriends}">
    <div class="row" id="enrollment-friends" ng-show="!noFriends">
        <div
         infinite-scroll="enrollCtrl.retYearAndSem()"
         infinite-scroll-disabled='!{{showMoreFriends}}'
         infinite-scroll-parent='true'>
            <div class="col-md-2" ng-repeat="friend in friends" style="margin-bottom:10px;">

然而这不起作用。所以我尝试了一些稍微不同的东西

<div class="course-enrollment-friends" ng-class="{'friends-paginated':showMoreFriends}">
    <div class="row" id="enrollment-friends" ng-show="!noFriends">
        <div
         infinite-scroll="enrollCtrl.retYearAndSem()"
         infinite-scroll-disabled='!{{showMoreFriends}}'
         infinite-scroll-container='.course-enrollment-friends'>
            <div class="col-md-2" ng-repeat="friend in friends" style="margin-bottom:10px;">

我做错了什么?

2 个答案:

答案 0 :(得分:0)

this thread的答案中,您似乎忘记了双引号:

  

此示例中的无限滚动容器的值为   双引号类名.content然后用单引号括起来。如果   你读取了源代码,最终会输入字符串值   document.querySelector。您可以阅读相关文档   它期望的价值。

没有双引号.course-enrollment-friends作为变量名传入,而不是作为必需字符串传递。

所以

infinite-scroll-container='".course-enrollment-friends"'

而不是

infinite-scroll-container='.course-enrollment-friends'

答案 1 :(得分:0)

尝试删除无限滚动禁用中给定值的大括号。使用:

<div
     infinite-scroll="enrollCtrl.retYearAndSem()"
     infinite-scroll-disabled='!showMoreFriends'
     infinite-scroll-container='.course-enrollment-friends'>

而不是:

<div
     infinite-scroll="enrollCtrl.retYearAndSem()"
     infinite-scroll-disabled='!{{showMoreFriends}}'
     infinite-scroll-container='.course-enrollment-friends'>