无限列表重复前3项

时间:2015-02-08 19:35:15

标签: angularjs ionic-framework

我有以下代码作为离子/角度应用程序。它有效,但由于某种原因,第一个结果重复3次。其余的似乎没问题

.controller('PlaylistsCtrl', function($scope,$http, $log) {

        var count = 0;
        $scope.peopledata = [];
        $scope.loadMore = function () {
            var xsrf = $.param({Offset: count, Count: 1});
            $http({
                method: 'POST',
                url: 'http://*****/GetVideos.asmx/GetVids',
                data: xsrf,
                headers: {'Content-Type': 'application/x-www-form-urlencoded'}
            }).success(function(data) {
                //$log.info(data.length);
                if(data.length === 0){
                    $scope.noMoreItemsAvailable = true;
                }
               $log.info(count);
                count = count + 1;
                for (var i=0; i<data.length; i++){
                    $scope.peopledata.push(data[i]);

                }

                $scope.$broadcast('scroll.infiniteScrollComplete');
                $log.info($scope.peopledata);
            });
        };
        $scope.loadMore();
        $scope.$on('$stateChangeSuccess', function () {
            $scope.loadMore();
        });

    })

标记:

<ion-view view-title="Test">
    <ion-content>
            <div class="list list-inset ">
                <a class="item item-thumbnail-left minheight-80" href="#/app/playlists/{{vid.vURL | trusted}}" ng-repeat="vid in peopledata">
                    <img ng-src="http://img.youtube.com/vi/{{vid.vURL}}/0.jpg">
                    <h2>{{vid.vTitle}}</h2>
                    <p>4 Upvotes 5 Downvotes</p>
                </a>
            </div>
        <ion-infinite-scroll
                ng-if="!noMoreItemsAvailable"
                on-infinite="loadMore()"
                distance="10%">
        </ion-infinite-scroll>
    </ion-content>
</ion-view>

0 个答案:

没有答案