I am facing a situation where I need to handle a select dropdown list (classification array). If the select list contains multiple values, it should be displayed as a dropdown. However, if there is only one element in the array, it should be automatically selected in the dropdown without the need for selection. I am looking to implement a condition wherein if the classification element length is less than or equal to 1, the element should be pre-selected in mat-select or the list should be displayed. Any advice on how to achieve this would be highly appreciated.
<form [formGroup]="myForm">
<div formGroupName="Details">
<mat-form-field appearance="outline">
<mat-label class="required">Classification</mat-label>
<mat-select
formControlName="classification"
>
<mat-option
*ngFor="let type of classification"
[value]="type.definedCode"
>
{{ type.definedMessage }}
</mat-option>
</mat-select>
</mat-form-field>
TsFile
classification: any =[
{
"definedSetValueCode":"Dry",
"definedSetValueIntMessage":"Seco"
}
],