2017-01-16 9 views
0

こんにちは、下のドロップダウン私のHTMLコードです。角度JSで選択したオプションを設定できませんか?

<div class="panelProfileDefault col-md-11" ng-repeat="profile in allPanelData"> 
    <form name="updateProfile" class="setProfile" ng-submit="updateProfile(updateProfile)" novalidate> 
       <div class="modal-body col-md-10"> 
        <div class="form-group col-md-5" ng-class="{ 'has-error' : updateProfile.profileName.$invalid && updateProfile.profileName.$dirty}"> 
          <div class="col-sm-12 col-md-12"> 
           <input type="text" class="" id="profileName" name="profileName" ng-model="profile.Name" placeholder="Element" required ng-disabled="isDisabled"/> 
           <div ng-messages='setProfile.profileName.$error' ng-if='submitted || setProfile.profileName.$dirty'> 
            <div ng-message='required' class="has-error">Please Enter the value for this field</div> 
           </div> 
          </div> 
        </div> 

        <div class="form-group col-md-5" ng-class="{ 'has-error' : setProfile.profileType.$invalid && setProfile.profileType.$dirty}"> 
         <div class="col-sm-12 col-md-12"> 
          <select class="transparent-textbox" ng-model="profile.TypeID" name="profileType" required ng-disabled="isDisabled"> 
            <option value="0" disabled>Element Type</option> 
            <option value="1">Text</div> 
            <option value="2">Float</div> 
            <option value="3">Date</div> 
            <option value="4">Object</div> 
            <option value="5">Long</div> 
          </select> 
          <div ng-messages='setProfile.profileType.$error' ng-if='submitted || setProfile.profileType.$dirty'> 
           <div ng-message='required' class="has-error">Please select the profileType</div> 
          </div> 
         </div> 
        </div> 
       </div> 
    </form> 
</div> 

私がしていることは、いくつかのdivをクリックして、1つのAPIを呼び出し、応答としてデータを取得しています。私は$を慰めるとき

$http.get(__env.apiUrl+'/UserPanelPanellists/GetProfileVariables?panelID=' + panelId, { 
         headers: { 'Content-Type': 'application/json','SessionID':$rootScope.token} 
        }).then(function(success){ 
        console.log(success.data); 
         $scope.allPanelData = success.data; 
         $scope.$emit('unload'); 
        },function(http, status, fnc, httpObj){ 
        $scope.$emit('unload'); 
        console.log('data retrieval failed.',http,status,httpObj); 
       }); 

が、今$scope.allPanelData.TypeID =1は、値=でオプションを選択した場合の選択ドロップダウンIEのデータを表示することができませんが「1」にも他人のため

を選択し、同じ取得する必要がありますscope.allPanelDataこれは次のようになります。

enter image description here

どのようにそれを修正するには?

答えて

1

ng-repeatの代わりにng-optionsを使用できますか?その後、

$scope.typeOpts = [ 
        {type: "Text", id : 1 }, 
        {type: "Float", id : 2 }, 
        {type: "Date", id : 3 }, 
        {type: "Object" , id : 4 }, 
        {type: "Long" , id : 5 } 
        ]; 

とそのようにそれを使用します。

<select class="transparent-textbox" ng-model="profile.TypeID" name="profileType" required ng-disabled="isDisabled" 
    data-ng-options=" type.id as type.type for type in typeOpts "> 
     <option value="0">Element Type</option> 
</select> 
関連する問題