Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 644
nativegrip Avatar asked Dec 19 '22 05:12

nativegrip


1 Answers

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>
like image 98
Gaurav Srivastava Avatar answered Apr 01 '23 07:04

Gaurav Srivastava