I currently have a select field implemented in my Angular component:
<select class="form-control" [(ngModel)]="myClient.address && myClient.address.state" name="state" (ngModelChange)="getCitiesByState($event)">
<option class="form-control" *ngFor="let state of states"
[ngValue]="state">
{{state.name}}</option>
</select>
As I'm using this component in multiple places, I'm looking for a way to set the selected option based on the value of my ngModel
. If, for instance,
myClient.address = {"name":"Texas", "stateId":"2"}
, then Texas should be pre-selected in the dropdown menu.
Is there a method to achieve this functionality?