Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 2+ set standard Form field appearance value

Working actually on form fields, I'm only using an outline appearance for my inputs (see more here).

Not wanting to copy appearance=outline everywhere on each form, I wanted to know if there was a way to set the standard value of the appearance on outline.

I've found out in the API that there is a MAT_FORM_FIELD_DEFAULT_OPTIONS (link). But I don't know how to use it and didn't found much documentation on it.


Or maybe should I just stick with a basic appearance="{{defaultAppearance}}" on each form field and set a global variable, but I still have to duplicate this code everywhere (but it still allows me change the style easily whenever I want to)

like image 333
Joël-Etienne Avatar asked Jan 22 '19 11:01

Joël-Etienne


1 Answers

Got the answer here.

add this:

{ provide: MAT_FORM_FIELD_DEFAULT_OPTIONS, useValue: { appearance: 'outline' }}

in the providers of @ngModule.

like image 129
Joël-Etienne Avatar answered Nov 04 '22 09:11

Joël-Etienne