ngFor
を使用して、双方向バインドselect
のドロップダウンを作成していますが、これは正常に動作していますが、ページがロードされていないときはoption
が選択されています。私は[selected]
で試しましたが、何も起こりません...どんなタフツ?双方向のバインドされた選択ドロップダウンでオプションが選択されていませんか?
コード:
<ng-container *ngFor="let attribute of details.Attributes">
<tr *ngIf="attribute.IsConfigurator == 'true'">
<td align="right">{{attribute.PropertyName}}</td>
<td>
<select [(ngModel)]="config[attribute.Pid]" (ngModelChange)="updateConfig()" class="form-control">
<option *ngFor="let values of attribute.Values; let i = index" value="{{values.Vid}}" [selected]="i == 0">{{values.Value}}</option>
</select>
</td>
</tr>
</ng-container>
私は10個の 'select'ドロップダウンを私のページに持っているので、' ngModel'として 'selected'を使うことはできません... –
他の方法を使っても10個の異なる変数が必要です – Sajeetharan