How to create infinite scroll in angularjs











up vote
0
down vote

favorite












I have an array of response that came from the server with pagination. I want whenever a user scrolls down for more result the next page data should be loaded. Until user did not scroll down the data came from only page 1 and when user scroll down the page should be changed as 2,3,4,.. so on.
can anyone help me to create infinite scroll in angularjs.










share|improve this question




























    up vote
    0
    down vote

    favorite












    I have an array of response that came from the server with pagination. I want whenever a user scrolls down for more result the next page data should be loaded. Until user did not scroll down the data came from only page 1 and when user scroll down the page should be changed as 2,3,4,.. so on.
    can anyone help me to create infinite scroll in angularjs.










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I have an array of response that came from the server with pagination. I want whenever a user scrolls down for more result the next page data should be loaded. Until user did not scroll down the data came from only page 1 and when user scroll down the page should be changed as 2,3,4,.. so on.
      can anyone help me to create infinite scroll in angularjs.










      share|improve this question















      I have an array of response that came from the server with pagination. I want whenever a user scrolls down for more result the next page data should be loaded. Until user did not scroll down the data came from only page 1 and when user scroll down the page should be changed as 2,3,4,.. so on.
      can anyone help me to create infinite scroll in angularjs.







      angularjs scroll






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 13 at 7:40









      Mukyuu

      3191216




      3191216










      asked Nov 13 at 1:57









      user10428712

      96




      96
























          2 Answers
          2






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          You can refer my sample, what I apply for table



          Html code :



          <div ng-controller="appController">

          <h1>This is my {{title}} Items: {{numberToDisplay}}/{{totalDisplay}}</h1>
          <div class="constrained">
          <table class="table table-striped" id="loggingTable" infinite-scroll="loadMore()" infinite-scroll-container='".constrained"' infinite-scroll-distance="1" infinite-scroll-parent="true">
          <tr data-ng-show="logEventFilter.length === 0">
          <td class="center" colspan="3">Nobody is here</td>
          </tr>

          <tr data-ng-repeat="logEvent in logEventFilter = (logEvents | limitTo:numberToDisplay) track by $index">
          <td> {{$index}} </td>
          <td> {{logEvent.name}} </td>
          <td> {{numberToDisplay}} </td>
          </tr>
          </table>
          </div>

          </div>


          Angularjs code :



             var app = angular.module('app', ['infinite-scroll'])
          .controller('appController', appController);

          appController.$inject = ['$scope', '$window'];

          function appController($scope, $window) {

          $scope.title = "infinite scroll example";
          $scope.numberToDisplay = 20;
          $scope.totalDisplay = 500;
          $scope.logEvents = ;
          for (var i = 0; i < $scope.totalDisplay; i++) {
          $scope.logEvents.push({
          name: "Hello, my name is " + i
          });
          }

          $scope.loadMore = function() {
          if ($scope.numberToDisplay + 5 < $scope.logEvents.length) {
          $scope.numberToDisplay += 5;
          } else {
          $scope.numberToDisplay = $scope.logEvents.length;
          }
          };
          };


          sample scroll infinite






          share|improve this answer





















          • Thanks @thanhdung0312 for the help
            – user10428712
            Nov 15 at 9:09










          • you're welcome @user10428712
            – thanhdung0312
            Nov 15 at 9:10


















          up vote
          0
          down vote













          you can you angular ui scroll



          This helps in loading the data as and when the user scrolls down.






          share|improve this answer





















          • As I told I have multiple page data in different page number, when scroll to bottom then one by one each page number (API) is getting hit. How can I achieve this in angular ui scroll?
            – user10428712
            Nov 13 at 9:14











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53272686%2fhow-to-create-infinite-scroll-in-angularjs%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          1
          down vote



          accepted










          You can refer my sample, what I apply for table



          Html code :



          <div ng-controller="appController">

          <h1>This is my {{title}} Items: {{numberToDisplay}}/{{totalDisplay}}</h1>
          <div class="constrained">
          <table class="table table-striped" id="loggingTable" infinite-scroll="loadMore()" infinite-scroll-container='".constrained"' infinite-scroll-distance="1" infinite-scroll-parent="true">
          <tr data-ng-show="logEventFilter.length === 0">
          <td class="center" colspan="3">Nobody is here</td>
          </tr>

          <tr data-ng-repeat="logEvent in logEventFilter = (logEvents | limitTo:numberToDisplay) track by $index">
          <td> {{$index}} </td>
          <td> {{logEvent.name}} </td>
          <td> {{numberToDisplay}} </td>
          </tr>
          </table>
          </div>

          </div>


          Angularjs code :



             var app = angular.module('app', ['infinite-scroll'])
          .controller('appController', appController);

          appController.$inject = ['$scope', '$window'];

          function appController($scope, $window) {

          $scope.title = "infinite scroll example";
          $scope.numberToDisplay = 20;
          $scope.totalDisplay = 500;
          $scope.logEvents = ;
          for (var i = 0; i < $scope.totalDisplay; i++) {
          $scope.logEvents.push({
          name: "Hello, my name is " + i
          });
          }

          $scope.loadMore = function() {
          if ($scope.numberToDisplay + 5 < $scope.logEvents.length) {
          $scope.numberToDisplay += 5;
          } else {
          $scope.numberToDisplay = $scope.logEvents.length;
          }
          };
          };


          sample scroll infinite






          share|improve this answer





















          • Thanks @thanhdung0312 for the help
            – user10428712
            Nov 15 at 9:09










          • you're welcome @user10428712
            – thanhdung0312
            Nov 15 at 9:10















          up vote
          1
          down vote



          accepted










          You can refer my sample, what I apply for table



          Html code :



          <div ng-controller="appController">

          <h1>This is my {{title}} Items: {{numberToDisplay}}/{{totalDisplay}}</h1>
          <div class="constrained">
          <table class="table table-striped" id="loggingTable" infinite-scroll="loadMore()" infinite-scroll-container='".constrained"' infinite-scroll-distance="1" infinite-scroll-parent="true">
          <tr data-ng-show="logEventFilter.length === 0">
          <td class="center" colspan="3">Nobody is here</td>
          </tr>

          <tr data-ng-repeat="logEvent in logEventFilter = (logEvents | limitTo:numberToDisplay) track by $index">
          <td> {{$index}} </td>
          <td> {{logEvent.name}} </td>
          <td> {{numberToDisplay}} </td>
          </tr>
          </table>
          </div>

          </div>


          Angularjs code :



             var app = angular.module('app', ['infinite-scroll'])
          .controller('appController', appController);

          appController.$inject = ['$scope', '$window'];

          function appController($scope, $window) {

          $scope.title = "infinite scroll example";
          $scope.numberToDisplay = 20;
          $scope.totalDisplay = 500;
          $scope.logEvents = ;
          for (var i = 0; i < $scope.totalDisplay; i++) {
          $scope.logEvents.push({
          name: "Hello, my name is " + i
          });
          }

          $scope.loadMore = function() {
          if ($scope.numberToDisplay + 5 < $scope.logEvents.length) {
          $scope.numberToDisplay += 5;
          } else {
          $scope.numberToDisplay = $scope.logEvents.length;
          }
          };
          };


          sample scroll infinite






          share|improve this answer





















          • Thanks @thanhdung0312 for the help
            – user10428712
            Nov 15 at 9:09










          • you're welcome @user10428712
            – thanhdung0312
            Nov 15 at 9:10













          up vote
          1
          down vote



          accepted







          up vote
          1
          down vote



          accepted






          You can refer my sample, what I apply for table



          Html code :



          <div ng-controller="appController">

          <h1>This is my {{title}} Items: {{numberToDisplay}}/{{totalDisplay}}</h1>
          <div class="constrained">
          <table class="table table-striped" id="loggingTable" infinite-scroll="loadMore()" infinite-scroll-container='".constrained"' infinite-scroll-distance="1" infinite-scroll-parent="true">
          <tr data-ng-show="logEventFilter.length === 0">
          <td class="center" colspan="3">Nobody is here</td>
          </tr>

          <tr data-ng-repeat="logEvent in logEventFilter = (logEvents | limitTo:numberToDisplay) track by $index">
          <td> {{$index}} </td>
          <td> {{logEvent.name}} </td>
          <td> {{numberToDisplay}} </td>
          </tr>
          </table>
          </div>

          </div>


          Angularjs code :



             var app = angular.module('app', ['infinite-scroll'])
          .controller('appController', appController);

          appController.$inject = ['$scope', '$window'];

          function appController($scope, $window) {

          $scope.title = "infinite scroll example";
          $scope.numberToDisplay = 20;
          $scope.totalDisplay = 500;
          $scope.logEvents = ;
          for (var i = 0; i < $scope.totalDisplay; i++) {
          $scope.logEvents.push({
          name: "Hello, my name is " + i
          });
          }

          $scope.loadMore = function() {
          if ($scope.numberToDisplay + 5 < $scope.logEvents.length) {
          $scope.numberToDisplay += 5;
          } else {
          $scope.numberToDisplay = $scope.logEvents.length;
          }
          };
          };


          sample scroll infinite






          share|improve this answer












          You can refer my sample, what I apply for table



          Html code :



          <div ng-controller="appController">

          <h1>This is my {{title}} Items: {{numberToDisplay}}/{{totalDisplay}}</h1>
          <div class="constrained">
          <table class="table table-striped" id="loggingTable" infinite-scroll="loadMore()" infinite-scroll-container='".constrained"' infinite-scroll-distance="1" infinite-scroll-parent="true">
          <tr data-ng-show="logEventFilter.length === 0">
          <td class="center" colspan="3">Nobody is here</td>
          </tr>

          <tr data-ng-repeat="logEvent in logEventFilter = (logEvents | limitTo:numberToDisplay) track by $index">
          <td> {{$index}} </td>
          <td> {{logEvent.name}} </td>
          <td> {{numberToDisplay}} </td>
          </tr>
          </table>
          </div>

          </div>


          Angularjs code :



             var app = angular.module('app', ['infinite-scroll'])
          .controller('appController', appController);

          appController.$inject = ['$scope', '$window'];

          function appController($scope, $window) {

          $scope.title = "infinite scroll example";
          $scope.numberToDisplay = 20;
          $scope.totalDisplay = 500;
          $scope.logEvents = ;
          for (var i = 0; i < $scope.totalDisplay; i++) {
          $scope.logEvents.push({
          name: "Hello, my name is " + i
          });
          }

          $scope.loadMore = function() {
          if ($scope.numberToDisplay + 5 < $scope.logEvents.length) {
          $scope.numberToDisplay += 5;
          } else {
          $scope.numberToDisplay = $scope.logEvents.length;
          }
          };
          };


          sample scroll infinite







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 15 at 8:43









          thanhdung0312

          1667




          1667












          • Thanks @thanhdung0312 for the help
            – user10428712
            Nov 15 at 9:09










          • you're welcome @user10428712
            – thanhdung0312
            Nov 15 at 9:10


















          • Thanks @thanhdung0312 for the help
            – user10428712
            Nov 15 at 9:09










          • you're welcome @user10428712
            – thanhdung0312
            Nov 15 at 9:10
















          Thanks @thanhdung0312 for the help
          – user10428712
          Nov 15 at 9:09




          Thanks @thanhdung0312 for the help
          – user10428712
          Nov 15 at 9:09












          you're welcome @user10428712
          – thanhdung0312
          Nov 15 at 9:10




          you're welcome @user10428712
          – thanhdung0312
          Nov 15 at 9:10












          up vote
          0
          down vote













          you can you angular ui scroll



          This helps in loading the data as and when the user scrolls down.






          share|improve this answer





















          • As I told I have multiple page data in different page number, when scroll to bottom then one by one each page number (API) is getting hit. How can I achieve this in angular ui scroll?
            – user10428712
            Nov 13 at 9:14















          up vote
          0
          down vote













          you can you angular ui scroll



          This helps in loading the data as and when the user scrolls down.






          share|improve this answer





















          • As I told I have multiple page data in different page number, when scroll to bottom then one by one each page number (API) is getting hit. How can I achieve this in angular ui scroll?
            – user10428712
            Nov 13 at 9:14













          up vote
          0
          down vote










          up vote
          0
          down vote









          you can you angular ui scroll



          This helps in loading the data as and when the user scrolls down.






          share|improve this answer












          you can you angular ui scroll



          This helps in loading the data as and when the user scrolls down.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 13 at 8:41









          Anjana G

          842




          842












          • As I told I have multiple page data in different page number, when scroll to bottom then one by one each page number (API) is getting hit. How can I achieve this in angular ui scroll?
            – user10428712
            Nov 13 at 9:14


















          • As I told I have multiple page data in different page number, when scroll to bottom then one by one each page number (API) is getting hit. How can I achieve this in angular ui scroll?
            – user10428712
            Nov 13 at 9:14
















          As I told I have multiple page data in different page number, when scroll to bottom then one by one each page number (API) is getting hit. How can I achieve this in angular ui scroll?
          – user10428712
          Nov 13 at 9:14




          As I told I have multiple page data in different page number, when scroll to bottom then one by one each page number (API) is getting hit. How can I achieve this in angular ui scroll?
          – user10428712
          Nov 13 at 9:14


















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53272686%2fhow-to-create-infinite-scroll-in-angularjs%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How to change which sound is reproduced for terminal bell?

          Can I use Tabulator js library in my java Spring + Thymeleaf project?

          Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents