this related question
,
,
e.g., by team name
[
{name: 'Gene', team: 'team alpha'},
{name: 'George', team: 'team beta'},
{name: 'Steve', team: 'team gamma'},
{name: 'Paula', team: 'team beta'},
{name: 'Scruath of the 5th sector', team: 'team gamma'}
];
accepted answer
使用
ng-repeat
用一个
groupBy
我想要多个扩展面板,每个团队一个,当扩展时,显示参与的玩家。
<mat-expansion-panel ng-repeat="(key, value) in players | groupBy: 'team'">
<mat-expansion-panel-header>
<mat-panel-title>{{ key }}</mat-panel-title>
</mat-expansion-panel-header>
<li ng-repeat="player in value">
{{player.name}}
</li>
</mat-expansion-panel>
ng重复
不允许进入
mat-expansion-panel
*ngFor
是允许的,但我不知道怎么和
过滤器。
*ngFor="let player in players | groupBy: 'team'"