为应用程序中的所有输入设置默认指令 [英] Set default directive for all input in app

查看:89
本文介绍了为应用程序中的所有输入设置默认指令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将mat-form-field与自定义css一起使用,以更改外观像appearance="outline"指令.

I use mat-form-field with custom css in order to change the be look like appearance="outline" directive.

Angular Material v 7.2.1中将appearance="outline"添加到了mat-form-field选项中.

In Angular Material v 7.2.1 appearance="outline" was added to the mat-form-field options.

如何为应用程序中的每个输入字段声明appearance="outline"作为默认值?

How can I declare appearance="outline" as a default for each input fields in my app?

推荐答案

您可以尝试在@NgModule中注入mat-form-field默认选项:

you can try to inject mat-form-field default options in your @NgModule:

...
providers: [ 
   { provide: MAT_FORM_FIELD_DEFAULT_OPTIONS, useValue: { appearance: 'outline' } } 
],
...

https://github.com/angular/material2/issues/12765 ,但我相信已经解决了.

There was an issue with this https://github.com/angular/material2/issues/12765, but I believe it has been solved.

这篇关于为应用程序中的所有输入设置默认指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆