【问题标题】:How do I change the responses of a component in a ngFor addition to a Select, keep the others visible?如何更改 ngFor 除了 Select 中的组件的响应,保持其他组件可见?
【发布时间】:2019-12-04 16:23:13
【问题描述】:

当您选择项目“标题”时,它会隐藏输入。但是当我从另一个 ngFor 索引中选择另一个项目时,所选的输入“标题”会重新出现。

<select class="form-control col-sm-6" 
     id="groupField{{i}}" 
     name="groupField{{i}}" 
     [(ngModel)]="selectedGroupingFields[i]" 
     (ngModelChange)="changeValue($event, i)">

<option [ngValue]="i+'_'+field.id" 
     *ngFor="let field of columnDefinitions">{{field.name}}</option>
</select>

Sample

【问题讨论】:

  • 我的问题有什么问题?

标签: javascript angular typescript angular6 angular8


【解决方案1】:

试试这个:

<option [ngValue]="i+'_'+field.id" *ngFor="let field of columnDefinitions">{{field.name}}</option>

问题是该选项没有唯一的 id

【讨论】:

  • 谢谢,确实缺少索引,但是当您从另一个索引中选择另一个项目时仍然会不断变化
猜你喜欢
  • 1970-01-01
  • 2018-10-17
  • 1970-01-01
  • 2019-07-20
  • 1970-01-01
  • 2018-06-17
  • 2011-08-27
  • 2022-12-02
  • 1970-01-01
相关资源
最近更新 更多