我正在为select选项获取价值,我希望以我使用的形式获取所选的选项文本ReactiveFrom
[
{
"brokerId": 10,
"brokerName": "Kennedy, Shea Peter"
},
{
"brokerId": 51,
"brokerName": "Fernandez, Jaime"
},
{
"brokerId": 279,
"brokerName": "Stapleton, Bill "
},
{
"brokerId": 489,
"brokerName": "Marlow, Jeff D."
},
]
组件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>
有没有办法得到它。?
答案 0 :(得分:1)
你需要将值更改为属性绑定我在这里添加了一个工作示例来检查这一点 https://stackblitz.com/edit/working-example?file=app/app.component.html