I am using mat-optgroup and mat-option to create a dropdown using angular material. In one case, I have mat-optgroup's label as empty. I don't want to show the label in that case. Is there an option to show/hide only label (not it's options) in mat-optgroup?
<mat-optgroup [class.active]="attributeGroup.groupName != ''" *ngFor="let attributeGroup of
filteredAttributeList | async"
[label]="attributeGroup.groupName">
<mat-option class="search-filter-options"
*ngFor="let attribute of attributeGroup.groupValues"
[value]="attribute.value">{{attribute.id}}</mat-option>
</mat-optgroup>
You can add the class when the
attributeGroup.groupis empty and then use::ng-deepto hide the label using css.Full example here: https://stackblitz.com/edit/angular-vuc2br?file=src/app/select-optgroup-example.ts