Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何始终在mat select中独立于当前选择显示占位符_Html_Angular_Angular Material - Fatal编程技术网

Html 如何始终在mat select中独立于当前选择显示占位符

Html 如何始终在mat select中独立于当前选择显示占位符,html,angular,angular-material,Html,Angular,Angular Material,我希望mat select元素始终显示占位符,即使选择了选项 我的HTML代码: <mat-select [formControlName]="'language'" placeholder="Language"> <mat-option value="de">Deutsch</mat-option> <mat-option value="en">English</mat-option> </mat-select&

我希望mat select元素始终显示占位符,即使选择了选项

我的HTML代码:

<mat-select [formControlName]="'language'" placeholder="Language">
    <mat-option value="de">Deutsch</mat-option>
    <mat-option value="en">English</mat-option>
</mat-select>

德国
英语
当前行为是:选择语言后,占位符变小,移动到顶部,所选语言显示为大

我想要的是:当选择一种语言时,占位符仍然应该以大尺寸显示,所选语言不应该显示


我该怎么做呢?

您可以结合使用
floatLabel=“never”
mat select trigger

<mat-select [formControlName]="'language'" placeholder="Language" floatlLabel="never">
    <mat-select-trigger>Language</mat-select-trigger>
    <mat-option value="de">Deutsch</mat-option>
    <mat-option value="en">English</mat-option>
</mat-select>

语言
德国
英语

您没有提供
标签,在这种情况下,“如果未指定,占位符将用作标签。”(来自)

要禁用它,请提供标签,然后将其隐藏

<mat-label hidden></mat-label>
<mat-select [formControlName]="'language'" placeholder="Language">
    <mat-option value="de">Deutsch</mat-option>
    <mat-option value="en">English</mat-option>
</mat-select>

德国
英语