Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

164
Visualizações
Where should I place infinite-scroll="loadMore()" infinite-scroll-distance="1"

I'm trying to implement infinite scrolling with ng-infinite-scroll

original html code

<div id="topMain" ng-if="util.data.results.length > 0" class='txnResults'>
            <ts-result row="row" data-last-result="$last"
                       data-result-section-values="util.data"
                       ng-repeat="row in util.data.results track by $index">
            </ts-result>
            <div 
             more codes
            </div>
</div>

I added 'infinite-scroll' and the following code to my controller

            $scope.numberToDisplay = 10;
            $scope.loadMore = function () {
                alert("loadmore " + $scope.numberToDisplay)
                if ($scope.numberToDisplay + 5 < vm.data.results.length) {
                    $scope.numberToDisplay += 5;
                } else {
                    $scope.numberToDisplay = vm.data.results.length;
                }
            };

and changed the html code to

<div id="topMain" ng-if="util.data.results.length > 0" class='txnResults'>
                <ts-result row="row" data-last-result="$last"
                           data-result-section-values="util.data"
                           ng-repeat="row in test = (util.data.results |limitTo:numberToDisplay) track by $index">
                </ts-result>
                <div 
                 more codes
                </div>
    </div>

so where should I call loadMore()? I tried to follow the sample code and <div infinite-scroll="loadMore()" infinite-scroll-distance="1"> but loadMore() got called in loop till numberToDisplay = length before the screen got popultaed.

 <div id="topMain" ng-if="util.data.results.length > 0" class='txnResults'>
                <div infinite-scroll="loadMore()" infinite-scroll-distance="1">
                    <ts-result row="row" data-last-result="$last"
                               data-result-section-values="util.data"
                               ng-repeat="row in test = (util.data.results |limitTo:numberToDisplay) track by $index">
                    </ts-result>
            </div>
                    <div 
                     more codes
                    </div>
        </div>

Any thoughts? Thanks!

about 4 years ago · Santiago Gelvez
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda