【发布时间】:2020-01-28 22:11:58
【问题描述】:
我有这个垫子选择,我想按字母顺序排列。
<mat-select [(ngModel)]="item" name="item" (selectionChange)="changeIdentificationOptions($event)">
<mat-option *ngFor="let item of itemss" [value]="item">
{{ item.name ? item.name: item.identity}}
</mat-option>
</mat-select>
显示的选项名称是有条件的。每个项目都有一个可选的名称。如果确实有名称,则将使用它,否则将使用身份名称。
我在 SO 上看到建议进行自定义 orderBy 管道类似于此答案Angular Material - dropdown order items alphabetically
但是使用单个键进行排序。我在制作定制管道方面不是很有经验。这对我的情况如何?
【问题讨论】:
标签: angular typescript angular-pipe