inh_inh
inh_inh

Reputation: 21

How to repeat row in table in angular js

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

Upvotes: 0

Views: 134

Answers (1)

Santosh Kumar
Santosh Kumar

Reputation: 205

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>

Upvotes: 1

Related Questions