title: Passing parameter onclick, in a loop using angular8
body: <p>I have an array of objects. i am iterating that in loop and passing each item's name to <strong>onclick</strong> which targets a function <code>openIt(val)</code> in <code>app.js</code> file which is in assets folder. ie</p>
  
  <p>Angular Code:</p>
  
  <pre><code>&lt;div *ngFor="let item of listArray"&gt;
  &lt;button class="tabopen" onclick="openIt(item.name)"&gt;{{item.name}}&lt;/button&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>app.js Code:</p>
  
  <pre><code>function openIt(data) {
  console.log(data);
  }
  </code></pre>
  
  <p>In my <strong>openIt function</strong> in app.js file i am not getting <strong>item.name</strong>. In my console it displays error that <strong>item is not defined</strong>. But when i pass static data i.e <code>onclick="openIt('sample_data')"</code>it does not show any error.</p>
  
  <p>Even though item.name also exists i am getting correct values against this as well. I am not getting that why i am not able to pass iterative data to the parameters.</p>