AngularJs表中的数字计数

时间:2016-03-01 11:03:20

标签: angularjs

<table align="center">
    <tr>
        <th>No</th>
        <th>Movie Title</th>
    </tr>
        <tr data-ng-repeat="mov in movie | pagination: curPage * pageSize | limitTo: pageSize | filter:searchText" data-ng-show="showSuccessMessage" data-ng-click="selectMovie($event,mov)" data-ng-class="{'selected':selectedMovie.film_id===mov.film_id}" style="cursor: pointer;">
            <td>

            </td>
            <td>
                {{mov.title}}
            </td>
        </tr>
    </table>

Aboe代码工作正常,但我如何计算数字并显示在 ??

结果 enter image description here

2 个答案:

答案 0 :(得分:1)

您可以使用$index来获取数组中元素的索引。它从0开始。因此您可以使用$index + 1

进行打印

答案 1 :(得分:1)

试试这个

  <table align="center">
        <tr>
            <th>No</th>
            <th>Movie Title</th>
        </tr>
            <tr data-ng-repeat="mov in movie | pagination: curPage * pageSize | limitTo: pageSize | filter:searchText" data-ng-show="showSuccessMessage" data-ng-click="selectMovie($event,mov)" data-ng-class="{'selected':selectedMovie.film_id===mov.film_id}" style="cursor: pointer;">
                <td>
                   {{ $index + 1 }}
                </td>
                <td>
                    {{mov.title}}
                </td>
            </tr>
        </table>