Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

164
Views
how to pass index to a script in angularjs

I have the following angular.js code:

<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>

So basically I want to pass index to a script. If I couldn't do it, how can modify the code base to make it work?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can move the template code into the ng-repeat block.

<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>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!