Home > Net >  Access array inside another array of a datasource
Access array inside another array of a datasource

Time:03-25

 <wrapper-table [dataSource]="onlyScenarios"
                 [columns]="columns"
    <ng-container matColumnDef="workingPlaces">
        <th mat-header-cell
            *matHeaderCellDef
            scope="col">{{ 'MENU' | translate }}</th>
        <td mat-cell
            *matCellDef="let row">
            {{row.workingPlace}}
        </td>
    </ng-container>

I have this template and my datasource (onlyScenarios) is an array that contains another array (scenarios). As you can see in the mat-cell, i display the content of that object ({{row.workingPlace}}) but i need to display from the second array(scenarios). I mean something like

{{row.scenarios.workingPlace}}

The 'onlyScenarios' looks like this: https://imgur.com/a/oMzbzEH

How can i do that?

CodePudding user response:

If scenarios is also an array then to access it to you have to make sure you access that entry:

{{row.scenarios[0].workingPlace}}

Something like this.

CodePudding user response:

That sounds good, just be sure that your [dataSource] contains only the scenario array and not the object you posted

  • Related