Select 角度2,选择带有动态选项的问题

Select 角度2,选择带有动态选项的问题,select,angular,data-binding,options,Select,Angular,Data Binding,Options,在Angular 2中,我创建了一个带有动态选项的选择,选项(项目数组)将被更改 <select [(ngModel)]="itemFilter" (change)="onChange($event)"> <option *ngFor="let item of items" [ngValue]="item.name">{{item.name}}</option> </select> {{item.name} 项目数组为空,则选择为空且

在Angular 2中,我创建了一个带有动态选项的选择,选项(项目数组)将被更改

<select [(ngModel)]="itemFilter" (change)="onChange($event)">
    <option *ngFor="let item of items" [ngValue]="item.name">{{item.name}}</option>
</select>

{{item.name}
  • 项目数组为空,则选择为空且为空
  • 项目数组为[“abc”],选择包含的“abc”,然后我选择“abc”
  • 项目数组变为[“abc”,“def”]并选择包含的“abc”,“def”选项,但选定的“abc”变为空,ngModel仍为“abc”,但仅选择显示为空,看起来像是选择为空
  • 我假设ngModel值为“abc”,但选项(项数组)发生了更改,然后ngModel绑定被破坏,因此所选项变为空

    有没有人遇到过类似的问题