Angular-尝试从html选择标记中获取选项值的值时的Udefined值

问题描述 投票:0回答:1

我想在我的角度组件的选择标签中更改所选选项时获取值:

<select name="types" class="custom-select form-control rounded" (change)="changeType($event.target.value)">
  <option selected value="allTypes">Tous</option>
  <option *ngFor="let type of types; let i = index" [value]="types.id">
   {{types[i].name}
  </option>
</select>

  changeType(type) {
    this.chosenType = type
    console.log('changed type', type)
    this.getData()
  }

当日志选择类型时,我不确定!

html typescript select events option
1个回答
0
投票

使用ngValue解决问题

© www.soinside.com 2019 - 2024. All rights reserved.