1

I have a basic select element. I'm trying to give it a class with some attributes but the problem is that my class is overwritten by an angular class "ng-star-inserted". How can I force the element to take my class? HTML:

<mat-form-field appearance="fill">
  <mat-label>Cars</mat-label>
  <select matNativeControl required>
    <option value="volvo" [ngClass]="{'test':isBold}">Volvo</option>
    <option value="saab">Saab</option>
    <option value="mercedes">Mercedes</option>
    <option value="audi">Audi</option>
  </select>
</mat-form-field>

CSS:

.test{ //I tried here with ::ng-deep before the class but it's not working
  font-weight: bold;
}

TS:

//...code
isBold:boolean=true; //always true for now
anyway07
  • 227
  • 1
  • 4
  • 12

1 Answers1

0

Try by adding !important for the compiler to prioritize your code. If it doesn't work, try with ::ng-deep and !important

.test{
   font-weight: bold !important;
}

or

::ng-deep.test{
   font-weight: bold !important;
}