0
我在我的角度代码这个下拉列表:NG选项的如何获得所选选项的文本
HTML:
<select class="selected_location" ng-options="perlocation.id as perlocation.name for perlocation in locations" ng-model="cleaningServiceLocation">
<option value="">Please Select Location</option>
</select>
<p>{{cleaningServiceLocation}}</p>
渲染:
<select class="selected_location" ng-options="perlocation.id as perlocation.name for perlocation in locations" ng-model="cleaningServiceLocation">
<option value="" class="" selected="selected">Please Select Location</option>
<option value="string:loc1" label="Location Name">Location Name</option>
<option value="string:loc2" label="Other Name">Other Name</option>
</select>
当用户选择选项时,我需要获取选项内部文本,如“位置名称”。
但我们得到的期权价值,如 “LOC1”
是的,我们将perlocation.name和值显示为perlocation.id。 – CodeMan
我的意思是,你应该这样做'ng-options =“perlocation.name perlocation.name perlocation位置” – Kroderia