How to show Array of array in a dropdown inside mat-table and row matching the index of array

Viewed 19

I have an Array of array[n] i.e. [1]: https://i.stack.imgur.com/siFej.png I have to add this in mat table as one column for dropdown in each row and each array[i] should be used for dropdown in each row[i]

This is from HTML

<ng-container matColumnDef="alt_vehicle">
  <th mat-header-cell *matHeaderCellDef>Alternative Vehicle</th>
  <td mat-cell *matCellDef="let element">
    <select *ngIf="element.alt_vehicle" name="numberPlate" id="numberPlate">
        <option *ngFor="let plate of arrPlate">{{plate}}</option>
      </select>
  </td>
</ng-container>

This function is creating the Array of array

  arrPlate: Array<string[]>=[];

  splitt() {       //To convert comma seprated number plate values to array
    for (let i = 0; i < this.vehicles.length; i++) {
        const nPlate = this.vehicles[i].alt_vehicle;
        let splited =  nPlate.split(',');
        this.arrPlate = this.arrPlate.concat([splited]);
    }
    console.log(this.arrPlate)
  }

What i'm able to achieve is this [1]: https://i.stack.imgur.com/wS4Dy.png

But I want to have is like in row 1 , we will have dropdown 1 with option Array[array[1],...] for example ['YVJ168 - 6452', '202CAM - 6449', '302CAM - 6456', '1JFC047 - 6412', '1UQZ159 - 6420', '1VDE261 - 6424', '1VEL633 - 6422', '1WKH554 - 6435']

And for next row[i] will have dropdown[i] with option of Array[..,array[i],...] for example ['1CYK092 - 2716', '1CYY396 - 2703', '1CYZ336 - 2702', '1CYY395 - 2715', '1DYA393 - 2701', '1CYY393 - 2708', '1DYH888 - 2706']

I'm using Angular 11 and material table If need any more details please add it in answer Thanks.

0 Answers
Related