Tengo el siguiente código angular.js:
<table ng-repeat="item in myCollection"> <tr> <td> <span> <i uib-popover-template="'myPopoverTemplate'" <!--I want to pass $index to myPopoverTemplate--> popover-trigger="mouseenter" type="button"></i> <strong>{{item.Amount}}</strong> </span> </td> </tr> </table> <script type="text/ng-template" id="myPopoverTemplate"> <p>{{myCollection[...].reference}}</p> <!--pass index to here--> </script>Básicamente, quiero pasar el índice a un script. Si no pude hacerlo, ¿cómo puedo modificar el código base para que funcione?
Puede mover el código de la plantilla al bloque ng-repeat .
<table ng-repeat="item in myCollection"> <tr> <td> <span> <i uib-popover-template="'myPopoverTemplate'" popover-trigger="mouseenter" type="button"></i> <strong>{{item.Amount}}</strong> </span> </td> </tr> <script type="text/ng-template" id="myPopoverTemplate"> <p>{{item.reference}}</p> </script> </table>