angular - 如何应用样式属性 Angular 自动完成

标签 angular typescript

在我的 Angular 应用程序中,我有自动完成功能

template.html

<mat-form-field >
    <input matInput [matAutocomplete]="auto"  [formControl]="customerFilterControl">
       <mat-autocomplete #auto="matAutocomplete" [displayWith] = "displayFn">
         <mat-option *ngFor="let option of (filteredOptions | async);index as i" [value] ="option">
           {{option.name}}
         </mat-option>
       </mat-autocomplete>
   </mat-form-field>

enter image description here

如图所示的下拉菜单,我希望颜色为白色,文本颜色必须为黑色,该怎么做?

我尝试将 mat-autocomplete attr 的样式应用到 bg-color=white 和 color=black。但这并没有成功。请帮助我:)

我还想显示完整的单词,例如:应该显示 1069842(CADMinexxxxx) 而不是 1069842(CAD... enter image description here

最佳答案

覆盖样式,

::ng-deep mat-option {
  background-color: white;
}

关于angular - 如何应用样式属性 Angular 自动完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58992835/

相关文章:

angular - 无法使用 Select 以 Angular 4 react 形式隐藏然后显示控件

angular - (Angular 6)Angular Universal - 不等待内容 API 调用

javascript - typescript 错误地假定该属性是只读的

javascript - AngularJS + TypeScript + ES6 模块 : how to bundle for browser?

javascript - angular4 - 异步数据加载 - async ngFor 循环?

angular - Angular 6 中的 Observable<string> 类型上不存在属性 'publish'

javascript - Bootstrap 4 Modal 不适用于 Angular 2

node.js - 如何在nestjs中手动注入(inject)依赖

javascript - Typescript 验证器模式正则表达式在 Internet Explorer 中出现意外量词错误,但在 Google Chrome 中有效

html - 垫树水平滚动。如何添加?