Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. //on $htttp success...
  2. var dataRows = data; //data is your array with 2000 items
  3. var delay = 0; //in milliseconds
  4.  
  5. //var to be used in ngRepeat
  6. $scope.rows = [];
  7.  
  8. //each loop will extract the first objects from the array until the array is empty
  9. while(dataRows.length) {
  10. delay += 20; //time span between every timeout call
  11. //using $timeout so it creates a new thread (don't lock UI)
  12. $timeout(function () {
  13.  
  14. //take the first 50 items from the Array
  15. var thisChunk = dataRows.splice(0, 50);
  16.  
  17. //append the 50 items to the $scope var
  18. $scope.rows.push.apply($scope.rows, thisChunk);
  19.  
  20. }, delay);
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement