简体   繁体   English

在多行 mat-select 上隐藏第二行

[英]Hide second line on a multi-line mat-select

I have been tasked with creating a drop down that has the style of我的任务是创建一个具有以下样式的下拉菜单在此处输入图像描述

The code for this is代码是

<mat-select >
    <mat-option *ngFor="let type of source"
                style="min-height: 48px; line-height: normal; height: auto; padding: 10px 20px;" [value]="type.value">
        <div class="u-textSize14">{{type.displayName}}</div>
        <div class="u-textSize12">{{type.hint}}</div>
    </mat-option>
</mat-select>

When I select an option, the selected item appears as当我 select 一个选项时,选中的项目显示为

"Standard UrlDomainName.com", is there any way I could hide the second line / hint when an item is selected and make it only appear when the mat select is open “Standard UrlDomainName.com”,有什么办法可以在选择项目时隐藏第二行/提示并使其仅在垫子 select 打开时出现

To customize your selected option, use <mat-select-trigger> within the <mat-select> :要自定义您选择的选项,请在<mat-select>中使用<mat-select-trigger> > :

<mat-select [formControl]="foo">
    <mat-select-trigger>{{foo.value ? foo.value[0] : ''}}</mat-select-trigger>
    <mat-option *ngFor="let item of items" [value]="item.val">{{item.label}} - {{item.desc}}</mat-option>
</mat-select>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM