[英]Access array inside another array of a datasource
<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).我有这个模板,我的数据源 (onlyScenarios) 是一个包含另一个数组(场景)的数组。 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).
正如您在 mat-cell 中看到的那样,我显示了 object ({{row.workingPlace}}) 的内容,但我需要从第二个数组(场景)显示。 I mean something like
我的意思是像
{{row.scenarios.workingPlace}}
The 'onlyScenarios' looks like this: https://imgur.com/a/oMzbzEH “onlyScenarios”看起来像这样: https://imgur.com/a/oMzbzEH
How can i do that?我怎样才能做到这一点?
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.像这样的东西。
That sounds good, just be sure that your [dataSource] contains only the scenario array and not the object you posted听起来不错,只要确保您的 [dataSource] 仅包含场景数组而不是您发布的 object
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.