0

这是我在 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

但我想用 angular+HTML 写

我尝试这个但不工作

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

在我的控制器中

$scope.other_line =15;

请帮我解决它。谢谢

4

1 回答 1

1

ng-repeat 接受一个数组,你提供了一个值$scope.other_line =15;。ng-repeat 中的代码运行 array.length 次

所以你的代码应该像

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

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

当这将在浏览器中执行时,它将运行 15 次

<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>
于 2018-03-15T11:57:48.667 回答