0

我得到了选择选项的价值,我想以我使用 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>

有没有办法得到它。?

4

1 回答 1

1

您需要将值更改为属性绑定我在这里添加了一个工作示例,请查看 https://stackblitz.com/edit/working-example?file=app/app.component.html

于 2018-02-14T06:52:00.510 回答