垫选择长期权价值

时间:2019-03-19 03:38:42

标签: angular angular-material

我该如何处理Mat-select中的长值?

我可以添加水平滚动吗?
还是可以将多头期权的价值设为2行?

我尝试添加从here获得的虚拟滚动类,但出现错误

<mat-select formControlName="fieldOfWork" placeholder="Pilih bidang pekerjaan"  class="virtual-scroll" required>
   <mat-option [value]="null">Pilih bidang pekerjaan</mat-option>
   <mat-option *ngFor="let fieldOfWork of fieldOfWorks" [value]="fieldOfWork?.value">
      {{fieldOfWork?.label}}
   </mat-option>
</mat-select>

如何处理以下内容? enter image description here

2 个答案:

答案 0 :(得分:1)

将以下内容添加到您的style.css文件中

.mat-option-text {
  overflow: auto;
  text-overflow: unset;
}

Stackblitz Demo showing horizontal Scroll bar inside option

答案 1 :(得分:-1)

我还有另一个答案,它将把下拉面板的宽度设置为最长的值。你可以试试看我已经在有角度的材料中使用了它。

def double_word(word):
    return word + word + str(2*len(word))
相关问题