0

Here my code useing in php

@for($i= 0; $i < 15; $i++)
<tr>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
</tr>
@endfor

but I want write it with angular+HTML

I trying this but not work

<tr ng-repeat="rows in other_line">
    <td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
</tr>

In my controller

$scope.other_line =15;

please help me to resolve it. thanks

R. Richards
  • 24,603
  • 10
  • 64
  • 64
inh_inh
  • 21
  • 2
  • 1
    make `other_line` an array of 15 items. For example `$scope.other_line = new Array(15)`, `ng-repeat="rows in other_line track by $index"` – Aleksey Solovey Mar 15 '18 at 09:37
  • Possible duplicate of [AngularJS For Loop with Numbers & Ranges](https://stackoverflow.com/questions/11873570/angularjs-for-loop-with-numbers-ranges) – lin Mar 15 '18 at 10:05
  • Should be closed as duplicate. – lin Mar 15 '18 at 10:06

1 Answers1

1

ng-repeat takes an array , you have provided a value $scope.other_line =15;. Code inside ng-repeat runs array.length times

So your code should be like

$scope.other_line = [];
$scope.other_line.length = 15;

<div ng-repeat="rows in other_line">
  <td></td
</div>

When this will execute in browser then, it will run 15 times

<div ng-repeat="rows in other_line">
 <td></td
</div>
<div ng-repeat="rows in other_line">
 <td></td
</div>
<div ng-repeat="rows in other_line">
 <td></td
</div>
.
.
.
.
<div ng-repeat="rows in other_line">
 <td></td
</div>
Santosh Kumar
  • 205
  • 2
  • 6