角材质选择多个显示值

Mie*_* S. 1 html-select angular-material angular

是否可以在“角度材质”多重选择中更改显示值?我该怎么做,例如Products:(0/12)取决于所选项目的数量。

G. *_*ter 7

使用<mat-select-trigger>了点。例如:

<mat-form-field>
  <mat-select placeholder="Toppings" [formControl]="toppings" multiple>
    <mat-select-trigger>
      {{toppings.value ? toppings.value[0] : ''}}
      <span *ngIf="toppings.value?.length > 1" class="example-additional-selection">
        (+{{toppings.value.length - 1}} {{toppings.value?.length === 2 ? 'other' : 'others'}})
      </span>
    </mat-select-trigger>
    <mat-option *ngFor="let topping of toppingList" [value]="topping">{{topping}}</mat-option>
  </mat-select>
</mat-form-field>
Run Code Online (Sandbox Code Playgroud)

在此处查看演示:https : //stackblitz.com/angular/qkjbojyxebly?file=app%2Fselect-custom-trigger-example.html