troubleshooting Question

Angular - setting dropdown list value first time around

Avatar of Anthony Horner
Anthony Horner asked on
Angular
4 Comments1 Solution41 ViewsLast Modified:
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
ASKER CERTIFIED SOLUTION
leakim971
Multitechnician
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros