Winod Patel Winod Patel - 3 years ago 67
AngularJS Question

how to use ng-repeat loop by number of count in angularJS

I want to bind html table row by specific count times using angularJS binding like below:

<table>
<tr ng-repeat="x in 5">
<td>abc</td>
</tr>
</table>


If anybody have solution, please reply as possible.
Thanks

Answer Source

You can use constructor like this (no code in js required) :

var app = angular.module('myApp', []);

app.controller('myCtrl', function($scope) {

});
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>

<body>

  <div ng-app="myApp" ng-controller="myCtrl">
    <table>
      <tr ng-repeat="n in [].constructor(10)  track by $index">
        <td>abc</td>
      </tr>
    </table>
  </div>

</body>

</html>

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download