Wednesday 15 July 2015

javascript - AngularJS: Infinite scroll w/ -



javascript - AngularJS: Infinite scroll w/ <table> -

i have infinite scroll working w/ 1 set of info properly. when i'm doing similar task (image index) using html table, loadmore() function beingness called far often. 1 lite scroll go through whole set of data. google didn't give me specific illustration using table, wondering if i'm messing up.

<table> <span infinite-scroll="loadmore()" infinite-scroll-distance='2' infinite-scroll-disabled="load_disabled"> <tr data-ng-repeat="row in data"> <td data-ng-repeat="item in row"> <div class="image_box"> <img data-ng-src="{{item.thumb_src}}"><br>{{item.title_eng}} </div> </td> </tr> </span> </table>

javascript. note $scope.data array of arrays of items. $scope.data[0] have 5 items, hold thumbnail, , bit of text.

angular.module('myapp', ['ngroute','infinite-scroll']) .controller("imagecontroller", ['$scope', '$http', '$routeparams', '$rootelement', '$location', function($scope,$http,$routeparams,$rootelement,$location) { $scope.data = new array(); row = -1; ( var = 0; < 100; i++ ) { if ( % 5 == 0 ) { row++; $scope.data[row] = new array(); } var item = []; item["title_eng"] = "title " + i; $scope.data[row].push( item ); } console.log( "we got " + row + 1 + " rows." ); $scope.rows = new array(); var row_ix = 0; $scope.loadmore = function() { if ( !$scope.data[row_ix] || !$scope.data[row_ix].length ) { return; } var x = 1; // 1 @ time console.log( "row_ix: " + row_ix + "." ); ( var = 0; < x; i++ ) { $scope.rows[row_ix] = new array(); $scope.rows[row_ix] = $scope.data[row_ix].slice(0); row_ix++; } } angular.module('infinite-scroll').value('throttle_milliseconds', 250);\

edit: coming after time off. throttle seems not working. :(

javascript angularjs infinite-scroll nginfinitescroll

No comments:

Post a Comment