how can I add a consecutive id to each button?

1
<tr ng-repeat= "row in data | filter:getFilter">

    <td>{{row.folio}}/td>

    <td>{{row.fecha}}/td>

    <td>{{row.nombre}}/td>

    <td>{{row.usuario}}/td>

    <td>{{row.departamento}}/td>

    <td>{{row.descripccion}}/td>

    <td>{{row.correo}}/td>

    <td> button href="" id="" class="btn btn-success btn-xs" data-toggle="modal" data-target="#modal-aprobacion" ng-click="aprobar();">Aprobar /button>

    </td>

</tr>
    
asked by maribel garcia 29.10.2017 в 20:08
source

1 answer

1

I would do it with {{$ index}} that if we use it within an ng-repeat every time it is called, it returns the current iteration (0,1,2, ....), and if we concatenate it with a string invented by us we get a unique id. You see it clearer in your own code:

<tr ng-repeat= "row in data | filter:getFilter">

    <td>{{row.folio}}/td>

    <td>{{row.fecha}}/td>

    <td>{{row.nombre}}/td>

     <td>{{row.usuario}}/td>

    <td>{{row.departamento}}/td>

    <td>{{row.descripccion}}/td>

    <td>{{row.correo}}/td>

    <td> button href="" id="MiIndiceInventado{{$index}} class="btn btn-success btn-xs" data-toggle="modal" data-target="#modal-aprobacion" ng-click="aprobar();">Aprobar /button>

    </td>

</tr>

The "id" obtained would be:

MyIndexed Index0 MyIndexed Index1 MyIndexed Index2

and so on.

    
answered by 30.10.2017 в 02:05