Angular HTML select表单仅显示首选

伙计们,我有一个非常简单的代码段

<div class="form-group">
  <label for="exampleFormControlSelect1">Example select</label>
  <select class="form-control" id="exampleFormControlSelect1"  (change)="onChooseMenuItem($event.target.value)">
    <option selected disabled>Please select a program</option>
    <option
      style="cursor: pointer"
      *ngFor="let menuItem of ngrxMenuItems, let i = index"
      value={{i}}
    >{{menuItem.type}}
      </option>
  </select>
</div>

when i make a choice it always shows me the first option as selected. Let's say ngrxMenuItems is an array with [1,2,3,4]. No matter what is the choice you make it will show you only the first option.

我试过的  -删除(change)=“ onChooseMenuItem($ event.target.value)”并将其替换为每行上的(click)事件  -尝试ngIf选项

我认为是:  =一些我不知道的角度行为。

评论