Javascript 角度2选择框值
如何显示Javascript 角度2选择框值,javascript,html,angular,typescript,Javascript,Html,Angular,Typescript,如何显示selectBox中的选定值。我无法使用ngModel绑定属性,因为SelectBox的数量正在动态变化。 例如,我将有50个房间,因此每个selectBox需要50个变量。是否有其他方法来执行此操作,或者我必须使用选定值的数组?这是我当前的代码: <tr *ngFor="let room of term.rooms"> <th>{{room.name}}</th> <th><select #box><op
selectBox
中的选定值。我无法使用ngModel
绑定属性,因为SelectBox的数量正在动态变化。
例如,我将有50个房间,因此每个selectBox
需要50个变量。是否有其他方法来执行此操作,或者我必须使用选定值的数组?这是我当前的代码:
<tr *ngFor="let room of term.rooms">
<th>{{room.name}}</th>
<th><select #box><option *ngFor="let price of getPrices(room.id)" [ngValue]="price">{{price.name}}</option></select></th>
<th><!--ValueHere--></th><!--for example something like this price.value-->
</tr>
{{room.name}
{{price.name}
好的,您需要一个包含50个变量的数组
在模板中,使用ngFor
在数组中循环,对于每个变量,创建一个下拉列表并使用[(ngModel)]
绑定数据
如果你还是不明白,请告诉我