AngularJS Server side pagination on mouse scroll

青春壹個敷衍的年華 提交于 2019-12-11 16:24:18

问题


I am looking for some technique which will get me started to do server side pagination on mouse scroll. I have a large data set which I want to load in chunks and later dynamically load more on mouse scroll but at the server side. I came across ngInfiniteScroll but this looks like client side. Is there any method that can help me get started with this ?


回答1:


As of infinite scroll you could you use following example and change the loadMore() method so it calls server side just like this.

 $scope.loadMore = function () {
        $http.get('/someUrl').
        success(function (data, status, headers, config) {
            $scope.items.push(data); 
        }).
        error(function (data, status, headers, config) {
            // called asynchronously if an error occurs
            // or server returns response with an error status.
        });
    };



回答2:


What ngInfiniteScroll (http://binarymuse.github.io/ngInfiniteScroll/) does is load you "backend" by calling it each time a user scrolls, therefore what you need to implement is a backend written in your language of your preference that uses JSON (for simplicity sake or xml or whatever that can be parsed) to send data from your "massive dataset" by using some method of skip and steps where skip is the number of elements an index of the database are skipped and steps are the number of database registers from the the position of the skip index it is going to fetch.

So tell us which database technology are you using in order to implement the skip/steps technique for your infinite scroll.

ie:

MongoDB has Cursor Skip (more on that on the url below)

http://docs.mongodb.org/manual/reference/method/cursor.skip/



来源:https://stackoverflow.com/questions/26384968/angularjs-server-side-pagination-on-mouse-scroll

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!