如何获取选项选项ng-option的文本

时间:2016-06-28 12:55:46

标签: angularjs angularjs-scope

我的角度代码中有这个下拉列表:

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>

当用户选择选项时,我需要获得选项内部文本,例如&#34;位置名称&#34;。

但我们得到的选项价值如&#34; loc1&#34;

1 个答案:

答案 0 :(得分:0)

library(jsonlite) json = fromJSON("pathTofile.json") json status_code operation_id 1 200 13-10 response 1 {"emails":[{"campaign_id":"1111111","email_address":"1111@111","activity":[]},{"campaign_id":"22222","email_address":"2222@2222","activity":[]}]} 更改为perlocation.id as perlocation.name。第一个意味着您显示perlocation.name,其值为perlocation.id。