AngularJS - A simple infinite scroll

后端 未结 2 1974
予麋鹿
予麋鹿 2021-01-06 09:19

I am trying to write a similar small infinite scroll to the one found here: http://jsfiddle.net/vojtajina/U7Bz9/

I\'ve been able to display the first 5 pieces of dat

2条回答
  •  孤独总比滥情好
    2021-01-06 09:28

    There are two problems. First of all, what is attr.whenScrolled? Its undefined. Second one - limitTo: 5. You will allways show only 5 elements!

    Here you have working code: http://plnkr.co/edit/VszvMnWCGb662azo4wAv?p=preview

    What was changed? Your directive is called directiveWhenScrolled so call:

    scope.$apply(attr.directiveWhenScrolled);
    

    instead of

    scope.$apply(attr.whenScrolled);
    

    How lets deal with static limit. Change it into variable (remember about defining default value):

  • {{ i.Title }}
  • And now your loadMore function should look like this:

    $scope.loadMore = function() {
        $scope.limit += 5;
    };
    

提交回复
热议问题