Reputation: 1972
I am getting value for select option and I want to get the selected option text in the form I have used ReactiveFrom
[
{
"brokerId": 10,
"brokerName": "Kennedy, Shea Peter"
},
{
"brokerId": 51,
"brokerName": "Fernandez, Jaime"
},
{
"brokerId": 279,
"brokerName": "Stapleton, Bill "
},
{
"brokerId": 489,
"brokerName": "Marlow, Jeff D."
},
]
Component HTML:
<form [formGroup]="SplitBrokerForm">
<select formControlName="splitbrokerid1">
<option>-choose-</option>
<option *ngFor="let b of broker" value="{{b.brokerId}}" [selected]="b.brokerId == splitbrokerid1">{{b.brokerName}}</option>
</select>
</form>
is there any way to get it.?
Upvotes: 0
Views: 4941
Reputation: 27303
you need to change the value as a property binding i have added a working example here check this out https://stackblitz.com/edit/working-example?file=app/app.component.html
Upvotes: 1