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

3
  • 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" Commented Mar 15, 2018 at 9:37
  • Possible duplicate of AngularJS For Loop with Numbers & Ranges Commented Mar 15, 2018 at 10:05
  • Should be closed as duplicate. Commented Mar 15, 2018 at 10:06

1 Answer 1

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>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.