【发布时间】:2020-01-16 17:41:45
【问题描述】:
我正在尝试迭代两个数组,一个用于创建必要的选择字段,另一个用于填充每个选择字段中显示的选项。
<div *ngFor="let subject of subjects" class="input-field col s6"> //iterating through all the subjects
<mat-form-field>
<mat-label>{{subject}}</mat-label> /*creating select-field for each subject*/
<mat-select [(value)]="selectedStaff">
<mat-option *ngFor="let faculty of facultyNames" [value]="faculty" > /*iterating facultyNames to populate options*/
{{faculty}} /*populating options*/
</mat-option>
</mat-select>
</mat-form-field>
</div>
选择字段和选项按预期生成,但是当我在选择字段中选择一个选项时,其他选择字段的所有值也会更改为相同的选项。我无法为每个选择字段单独选择选项。
【问题讨论】:
标签: angular typescript angular-material ngfor