Set default directive for all input in app

倖福魔咒の 提交于 2019-12-23 17:15:54

问题


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

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

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


回答1:


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

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

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



来源:https://stackoverflow.com/questions/54398324/set-default-directive-for-all-input-in-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!