2016-08-04 13 views
1

を保持AngularJS - ドロップダウンが、私のAngularJSのWebアプリケーションで選択した値

Plunkerされていません。https://plnkr.co/edit/x9uIx5Inkxxt3fqttkkK?p=preview

ダウン私のドロップ(第一)の一つが選択された値を保持されていません。 htmlコードの断片は以下のとおりです。

は、私はマッピングNG-モデル=「entityPropertyType.propertyId」

entityPropertyTypeリストから反復値であるとは何かを知っています。

HTML

 <div class="form-group" ng-repeat="entityPropertyType in advancedSearch.entityPropertyTypes" > 

     <label class="control-label col-md-1">Business Card</label> 
     <div class="col-md-2"> 
      <select class="form-control" ng-model="entityPropertyType.propertyId" 
       ng-change="businessCardSelected($index, entityPropertyType.propertyId)" > 
       <option value="">Please select</option> 
       <option ng-repeat="property in businessCards" value="{{property.propertyId}}">{{property.propertyLabel}}</option> 
      </select> 
     </div> 


    </div> 
+0

が関連するかもしれない:http://stackoverflow.com/questions/26211573/angularjs-select-not-updating-when-ng-model-is ngOptionsディレクティブを使用します - 更新/ 26211704#26211704 – dfsq

答えて

1

あなたは、オプションの選択をレンダリングするためにngRepeatを使用しないでください。

<select class="form-control" 
     ng-options="property.propertyId as property.propertyLabel for property in businessCards" 
     ng-model="entityPropertyType.propertyId" 
     ng-change="businessCardSelected($index, entityPropertyType.propertyId)"> 
    <option value="">Please select</option> 
</select> 

デモ:https://plnkr.co/edit/v6KbJSkqu5XNz2LUfbrK?p=preview

+0

多くのおかげでそれは動作します.. – Jay

関連する問題