我应该在选择元素中绑定什么事件以检测选择更改?

时间:2019-01-14 21:02:26

标签: angular event-handling

我想更新表单页面上的插值文本,并且当用户在表单页面中选择新值时也要重新计算值

  <div class="form-group row">
    <label for="unitlabel" class="col-sm-2 col-form-label">Units</label>
    <select name="Units"
    [(ngModel)] = "units"
    (onTouched)="updateUnits()">
      <option value="US" selected>US</option>
      <option value="Metric">Metric</option>
    </select>
  </div>

1 个答案:

答案 0 :(得分:1)

参加change事件

<select name="Units"
[(ngModel)] = "units"
(change)="updateUnits()">