Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html ng-app="app">
<head>
<meta name="description" content="ng-repeater decrease performance to render dom as number of rows increases" />
<script src="http://code.jquery.com/jquery.min.js"></script>
<link href="http://twitter.github.io/bootstrap/assets/css/bootstrap.css" rel="stylesheet" type="text/css" />
<link href="http://twitter.github.io/bootstrap/assets/css/bootstrap-responsive.css" rel="stylesheet" type="text/css" />
<script src="http://twitter.github.io/bootstrap/assets/js/bootstrap.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.min.js"></script>
<meta charset=utf-8 />
<title>ng-repeater decrease performance to render dom as number of rows increases</title>
</head>
<body ng-controller="MainCtrl">
  <table class="table">
    <tr ng-repeat="d in data" render-time-bewtween-consecutive-rows><td>{{d}}</td></tr>
  </table>
  <btn class="btn" ng-click="loadMore()">Load more</btn>
</body>
</html>
 
var app = angular.module('app', []);
app.controller('MainCtrl', function ($scope) {
    $scope.refTime = (new Date()).getTime();
    
  //fake data
    count = 500;
    var data = [];  
    while(count) {
      data[count] = count--;
    } 
  
    $scope.data = data;
  
});
app.directive('renderTimeBewtweenConsecutiveRows', function(){
  
  function link($scope, element, attributes) {
    console.log("Time taken to render row - " + $scope.$index +' : ' + ((new Date()).getTime() - $scope.refTime) + ' ms');
    $scope.refTime = (new Date()).getTime();
  }
  return ({
    link: link,
    restrict: "A"
  });
  
});
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers