2017-02-10 44 views
0

我得到一個JSON值從一個WebService的這樣數據不被降下來填充從JSON響應從靜止在角JS

「電」:

{「selectedElectricityBoard」:」 ABCD」,

「electrictyConsumerNumber」: 「12345」,

「isElectricityBoardChecked」:真

}

我從JSON數據生成一個下拉列表,然後我選擇值並提交值,價值從我的用戶界面成功提交,現在的情況是我編輯相同的表單爲此,我正在進行一次Web服務調用,該調用返回的值與我從UI中選擇的值相同,但所選值未在下拉菜單中填充/反映,任何建議或幫助都將非常可觀,我的UI是JS角,代碼片段如下:

 <div class="col-xs-2 no-padding "> 
     <label>Consumer No.:</label> 
     </div> 
     <div class="col-xs-3"> 
     <span ng-hide="true" class="form-control" ng-required="true" 
     close-text="Close"> 
     </span> 
    <div class="group-3-text-boxes col-xs-3 no-padding" style="min-width: 100px;"> 
    <input type="text" name="consumer_number" 
ng-disabled="!form_data[selectedTab].electricity.isElectricityBoardChecked" 
ng-model="form_data[selectedTab].electricity.electrictyConsumerNumber" 
class="input-field" 
ng-class="{true:'invalid-field',false:''} 
form_data[selectedTab].electricity.isElectricityBoardChecked && form_data[selectedTab].invalid.electricity]" required /> 

+0

哪裏是在你的代碼下拉? –

回答

1
<html ng-app="app" ng-controller="ctrl"> 
<select id="state" ng-model="states" ng-options="state for (state,states) in total_states"> 
    <option value=''>Select State</option> 
</select> 
<select id="district" ng-model="districts" ng-options="district for (district,districts) in states"> 
    <option value=''>Select District</option> 
</select> 
<select id="city" ng-model="cities" ng-options="cities for cities in districts"> 
    <option value=''>Select City</option> 
</select> 
<br> 
<br> 
<br> 

State :: {{states}} 
<br> 
<br> 
<br> 
District:: {{districts}} 
<br> 
<br> 
<br> 
City :: {{cities}} 

的控制器:

app.controller('ctrl',ctrl); 
ctrl.$inject=['$scope']; 
function ctrl($scope) { 
    $scope.total_states = { 
     'Andhra Pradesh': { 
      'Prakasam': ['Ongole', 'Chirala', 'Mrakapuram'], 
      'Krishna': ['Vijayawada', 'Machalipatnam'], 
      'Guntur': ['Guntur', 'Tenali', 'Bapatla'] 
     }, 
     'Telangana': { 
      'Hyderabad': ['Hyderabad'], 
      'Warangal': ['Wrangal', 'Hanmkonda'], 
      'Khammam': ['Khmammam', 'Badrachalam'] 
     } 
    }; 

} 

試試這個它的工作原理...

+0

它沒有工作,在這裏我只附加你的plunker, 你會知道你的代碼不工作 https://plnkr.co/edit/cAO5s9kubHN4VJgdUnHu?p=preview – Mavericks