2

I have developed a chatting system like Facebook. Now I want to do load earlier messages. Can anyone help me to do the functionality like when I scroll up it should load earlier messages same like Facebook.

1 Answer 1

2

You may want to take a look at ngInfiniteScroll. With this module, it is very easy to implement what you want. Here is an example:

<div ng-app='myApp' ng-controller='DemoController'>
  <div infinite-scroll='loadMore()' infinite-scroll-distance='2'>
    <img ng-repeat='image in images' ng-src='http://placehold.it/225x250&text={{image}}'>
  </div>
</div>

var myApp = angular.module('myApp', ['infinite-scroll']);
myApp.controller('DemoController', function($scope) {
  $scope.images = [1, 2, 3, 4, 5, 6, 7, 8];

  $scope.loadMore = function() {
    var last = $scope.images[$scope.images.length - 1];
    for(var i = 1; i <= 8; i++) {
      $scope.images.push(last + i);
    }
  };
});

If you are using Bower, you can install if with bower install ngInfiniteScroll.

Sign up to request clarification or add additional context in comments.

4 Comments

yes, you are right but i want to add data on scroll up.Is it possible with ngInfiniteScroll?
no this isn't possible unfortunatley :( i have found github.com/LightZam/zInfiniteScroll works but i am having issues getting the scroll to stay where it is when it loads more
@Horse can you create issue for me to describe your problem?
guys, is there a way to transform element with ngInfiniteScroll in 180 degree? so it will be useful for scroll up. Do you think it's possible?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.