问题:如何实现mat-chipsin angular-material 在一行中(因为它们是标准的),但是当通过ngForin a mat-chip-list(在 a内mat-cell)循环时,它们被全部放置在单独的行上(参见“名称”列)。
目标:我希望将它排在每个旁边,直到由于宽度限制而中断(请参阅“重量”列)。
名称(例如 A、Z)的逗号分隔字符串元素的芯片应该在线上彼此相邻:
const ELEMENT_DATA: PeriodicElement[] = [
{position: 1, name: 'A, Z', weight: 1.0079, symbol: 'H'},
{position: 2, name: 'this first, this second in line', weight: 4.0026, symbol: 'He'},
];
Run Code Online (Sandbox Code Playgroud)
如
<ng-container matColumnDef="name">
<th mat-header-cell *matHeaderCellDef> Name </th>
<td mat-cell *matCellDef="let element">
<mat-chip-list class="no-wrap" *ngFor="let n of element.name.split(',')">
<span class="nobreak">
<mat-chip class="no-wrap">{{n}}</mat-chip>
</span>
</mat-chip-list>
</td>
</ng-container>
Run Code Online (Sandbox Code Playgroud)