Anisa Shaikh
Anisa Shaikh

Reputation: 1

how to set default value in select option when I have only two option?

here my code

<select class="form-control" 
   aria-placeholder="select auth type" id="auth_type" 
   [(ngModel)]="authenticationType" 
   name="auth_type"
   #auth_type="ngModel" 
   (change)="changeAuthenticationType($event)" required>
                    <option [ngValue]="undefined" disabled  selected>{{'AUTHENTICATION_CONFIGURATION.SELECT_TYPE' | translate}}
                    </option>
                    <option value="ALIGNOR_AUTHENTICATION">ALIGNOR AUTHENTICATION</option>
                    <option value="COGNITO_AUTHENTICATION">COGNITO AUTHENTICATION</option>
 </select> 

Upvotes: 0

Views: 58

Answers (1)

Shashank Vivek
Shashank Vivek

Reputation: 17494

You have not done it by the recommended way of doing it.

Refer this demo code to see how it done. I would recommend to do it this way.

<select [(ngModel)]="selectedItem">
  <option *ngFor="let item of items" [ngValue]="item">{{item.value}}</option>
</select>

You can make changes in your code accordingly.

Upvotes: 1

Related Questions