Avatar of Anthony Horner
Anthony Horner

asked on 

Angular - setting dropdown list value first time around

I have a drop-down in a header component which loads at log-in the legal entities that the user can view.
I'm not particular about which value is displayed but I would like there to be a value chosen, at the moment if there are 3 values to display the dropdown has 4 (a blank value which displays first).

The dropdown is populated the following way:

 <a *ngIf="jwtAuthenticationService.isUserLoggedIn()">legal entity:
    <select [(ngModel)]="selectedEntity" (change)="onSelectEntity()">
          <option *ngFor="let entity of legalEntity$" [ngValue]="entity">{{entity.legalEntityDesc}}
     </option>

Open in new window



I'm guessing that I'd need to set
selectedEntity

Open in new window

somehow in onInit after the data has been retrieved for that user?  How to do that, I've no (sensible) idea.

Help please
Angular

Avatar of undefined
Last Comment
Anthony Horner

8/22/2022 - Mon