title: UAngular 5: mat-table [dataSource] within *ngFor loop, how to pass data sources from an array
body: <p>what is the way to pass data sources from an array to a mat-table within *ngFor loop. I.e. I use *ngFor to create multiple tables, each table requires a datasource, but when I try the following it doesn't work: </p>
  
  <pre><code>&lt;mat-table #table [dataSource]="dataSources[i]"&gt; 
  </code></pre>
  
  <p>while 'i' is defined prior in html template:</p>
  
  <pre><code>&lt;mat-expansion-panel *ngFor="let customer of customers; let i = index"&gt; 
  </code></pre>
  
  <p><strong>Update:</strong></p>
  
  <p>the following worked for me, I added dataSource to each customer object instead of keeping it separate and trying to access via 'i' index</p>
  
  <pre><code>&lt;mat-table #table [dataSource]="customer.dataSource"&gt; 
  </code></pre>