【发布时间】:2018-07-25 03:47:09
【问题描述】:
我正在尝试将 Angular Material 用于基于模板的表单中的自动完成组件,但它基本上对输入的样式没有任何作用。
我已经按照official docs 中的说明导入了所有模块和样式,但没有任何变化,这就是我得到的:
这就是我想要的:
这是我的代码:
html:
<mat-form-field>
<input type="text" matInput [formControl]="myControl" name="myFirstMaterialComp" [matAutocomplete]="auto">
</mat-form-field>
<mat-autocomplete #auto="matAutocomplete">
<mat-option *ngFor="let location of locations | async" [value]="location.toponymName">
<span>{{ location.toponymName }}</span> |
</mat-option>
</mat-autocomplete>
而且我在 ts 中拥有所有导入以及 css 类的导入,我确信我错过了一些非常明显的东西,但我就是不知道是什么......
编辑为清楚起见:
我已经使用文档中提供的行导入了角度主题:
@import "~@angular/material/prebuilt-themes/indigo-pink.css";
【问题讨论】:
-
缺少材质主题
-
不,这是在我的 vendor.css 中导入的,如问题描述中所述,为了清楚起见,我将添加一行
-
您是否遵循 Angular Material 入门步骤?material.angular.io/guide/getting-started,第 4 步是您所缺少的
-
@Kld 请查看有问题的编辑
-
您确定您的其他依赖项都没有覆盖输入上的 css 吗?
标签: html angular typescript autocomplete angular-material