2016-06-28 5 views
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> 

いつでもユーザー選択オプション私は "場所名"のようなオプションの内部テキストを取得する必要があります。

しかし、我々はperlocation.name

答えて

0

変更perlocation.id as perlocation.name "LOC1" のようなオプションの値を取得します。最初はperlocation.nameを表示し、その値はperlocation.idです。

+0

はい、perlocation.nameとperlocation.idとして値を表示します。 – CodeMan

+0

つまり、 "ng-options =" perlocation.nameをperlocation.nameとして実行し、 " – Kroderia

関連する問題