![](/img/trans.png)
[英]Angular 6 Reactive Forms : How to set focus on first invalid input
[英]angular reactive forms - styling field color on invalid input
我正在使用 ReactiveForms,当输入无效时,我似乎找不到更改表单字段轮廓颜色的方法。
我需要更改此颜色,因为考虑到背景渐变,当前的红色并不是真正的最佳颜色,如您所见:
这是我的模板:
<mat-form-field appearance="outline" hideRequiredMarker>
<mat-label>{{ matLabel }}</mat-label>
<input
#input
matInput
type="{{ inputType }}"
[formControl]="control"
style="caret-color: white"
autocomplete="off"
/>
<mat-error style="color:white" *ngIf="control.invalid">{{ getErrorMessage() }}</mat-error>
...
</mat-form-field>
如何更改轮廓颜色?
先感谢您。
使用:host::ng-deep覆盖angular 材质样式
像这样试试
:host ::ng-deep .mat-form-field-appearance-outline.mat-form-field-invalid .mat-form-field-outline-thick,
:host ::ng-deep .mat-form-field.mat-form-field-invalid .mat-form-field-label, .mat-error {
color: purple !important;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.