AngularJS:行号

时间:2016-04-23 11:34:11

标签: html angularjs controller line

我会得到一些搜索结果如下:
enter image description here

使用 table 标签和AngularJS,如下所示:

      <tbody>
            <tr ng-repeat="customer in fndCtrl.result">
                <td>
                    1
                </td>
                <td ng-bind=":customer.CustomerNumber"></td>
                <td ng-bind=":customer.FirstName + ' ' + customer.LastName"></td>

我怎么设置行号,然后呢?我在上面设置了1个图像。

2 个答案:

答案 0 :(得分:0)

这样做 -

<tbody>
        <tr ng-repeat="customer in fndCtrl.result">
            <td>
                {{$index+1}}
            </td>
            <td ng-bind=":customer.CustomerNumber"></td>
            <td ng-bind=":customer.FirstName + ' ' + customer.LastName"></td>

答案 1 :(得分:0)

track by $index添加到ng-repeat。修改后的代码是

<tbody>
        <tr ng-repeat="customer in fndCtrl.result track by $index">
            <td>
                {{ $index + 1 }}
            </td>
            <td ng-bind=":customer.CustomerNumber"></td>
            <td ng-bind=":customer.FirstName + ' ' + customer.LastName">   </td>