Pass ID to modal via ng-repeat AngularJS

0

How to get the ID (prod.productoId) of the row in ng-repeat and change to modal to update the record. It should be something with ng-click on the button but I'm not finding any examples. Someone could help. Thanks!

<tr ng-repeat="prod in produtos">
  <td class="text-center">{{prod.produtoId}}</td>
  <td class="text-center">{{prod.produtoOperadora}}</td>
  <td>{{prod.produtoDesc}}</td>
  <td>{{prod.produtoPreco | currency}}
    <td>{{prod.produtoPrecoConv | currency}}</td>
    <td class="text-center">
      <button id="btn" class="btn btn-info btn-sm text-white" data-toggle="modal" data-target="#updateProd">
                                    <i class="fa fa-refresh"></i>
                                </button>
    </td>
</tr>
    
asked by anonymous 20.07.2018 / 15:44

1 answer

1

To send the id to a method in your js just put the click and call a method by passing the prod.produtoId as a parameter.

<button id="btn" class="btn btn-info btn-sm text-white" data-toggle="modal" data-target="#updateProd" ng-click="editar(prod.produtoId)">Editar</button>

No js

editar: function(id){

}

As the button is inside your repeat structure it will pick up the id corresponding to the row of your table.

    
23.07.2018 / 13:40