Angular material 我无法从字段更改mat中的占位符颜色

Angular material 我无法从字段更改mat中的占位符颜色,angular-material,Angular Material,我不会更改输入占位符文本的颜色。它在一个垫子抽屉里。我尝试了几种方法:添加一个新类,在dev工具中查找该元素的路径。我对更改背景没有问题,但文本颜色根本不会更改。 我需要一些指导 html文件 <div class="selected-column" style="height: 90%" fxFlex="10" fxFlex.xs="100"> <mat-form-field style="width: 100px"> <

我不会更改输入占位符文本的颜色。它在一个垫子抽屉里。我尝试了几种方法:添加一个新类,在dev工具中查找该元素的路径。我对更改背景没有问题,但文本颜色根本不会更改。 我需要一些指导

html文件

<div class="selected-column" style="height: 90%" fxFlex="10" fxFlex.xs="100">

        <mat-form-field style="width: 100px">
            <input matInput
                    placeholder="From Date"
                    [(ngModel)] = "dayStart"
                    [dpDayPicker]="config.global.datePickerConfig"
                    theme="dp-material" attachTo=".mat-form-field-wrapper"
                    (displayDate) = "dayStart"
            />


        </mat-form-field>
</div>

可能和有效的解决办法:

在基础组件中将封装设置为无,如:

import {Component, ViewEncapsulation } from '@angular/core';

/** @title Simple form field */
@Component({
  selector: 'form-field-overview-example',
  templateUrl: 'form-field-overview-example.html',
  styleUrls: ['form-field-overview-example.css'],
  encapsulation: ViewEncapsulation.None,  <--- here
})
export class FormFieldOverviewExample {}

可能的有效解决方案:

在基础组件中将封装设置为无,如:

import {Component, ViewEncapsulation } from '@angular/core';

/** @title Simple form field */
@Component({
  selector: 'form-field-overview-example',
  templateUrl: 'form-field-overview-example.html',
  styleUrls: ['form-field-overview-example.css'],
  encapsulation: ViewEncapsulation.None,  <--- here
})
export class FormFieldOverviewExample {}

尝试过的代码在哪里?我添加了我也尝试使用::ng deep。尝试过的代码在哪里?我添加了我也尝试使用::ng deep.ViewEncapsulation.None保存我的一天我以前从未使用过它。谢谢你的帮助,我今天学到了一些新东西:)没有其他选择吗?因为我不能改变Encapsulation@AhammadaliPK您可以使用
::ng deep
instead@AhammadaliPK这是一个正在运行的演示:谢谢,看起来不错,但是ng2-FlatPickerViewEncapsulation出现了问题。除了我的一天之外,我以前从未使用过它。谢谢你的帮助,我今天学到了一些新东西:)没有其他选择吗?因为我不能改变Encapsulation@AhammadaliPK您可以使用
::ng deep
instead@AhammadaliPK是一个工作演示:谢谢,看起来不错,但是ng2 FlatPicker有问题
.mat-focused .mat-form-field-label {
   color: red !important; -- on focus event
}

.mat-form-field-label {
   color: red !important;  -- for default color
}