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

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

问题描述

我使用带有自定义 css 的 mat-form-field 来改变看起来像 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.1appearance="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天全站免登陆