title: Angular: Get current index in ngFor
body: <p>I have following angular:</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;div class=&quot;test&quot; *ngFor=&quot;let item of data; let i = index&quot;&gt;
      {{item}}
  &lt;/div&gt;
  
  &lt;div class=&quot;function_div&quot; (click)=&quot;test(i);&quot;&gt;Test Button &lt;/div&gt;
  </code></pre>
  <p>then in <code>.ts</code>,</p>
  <pre class="lang-ts prettyprint-override"><code>export class test{
     
    test(){
       console.log(i);
    }
    
  }
  </code></pre>
  <p>I want to get a variable with the current index number.</p>
  <p>How would I go about so that I can get the current index?</p>
  <p>Thanks</p>