我想使用 mat-table 在角色列中显示用户的角色名称
用户.ts
export const User = [{
firstName: 'User',
lastName: '1',
roles: [{id: '1', roleName: 'first Role'},
{id: '2', roleName: 'second Role'}]
}, {
firstName: 'User',
lastName: '2',
roles: [{id: '1', roleName: 'third Role'},
{id: '2', roleName: 'fourth Role'}]
}];
Run Code Online (Sandbox Code Playgroud)
用户显示.html
<section>
<mat-table class="matTable" [dataSource]="dataSource">
<ng-container matColumnDef="firstName">
<mat-header-cell *matHeaderCellDef> First Name </mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.firstName}} </mat-cell>
</ng-container>
<ng-container matColumnDef="lastName">
<mat-header-cell *matHeaderCellDef> Last Name </mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.lastName}} </mat-cell>
</ng-container>
<ng-container matColumnDef="roles">
<mat-header-cell *matHeaderCellDef> Roles </mat-header-cell>
<mat-cell …Run Code Online (Sandbox Code Playgroud)