2017-12-05 18 views
1

私は、ドロップダウンとスコア値の値を取得するAPIを持っています。選択ボックスの値に基づいてAPIから値を取得する方法は?

API screenshot

1)私は、スクリーンショット、以下のように見えるUIを持っています。

UI screenshot

2)コードが下に記載されて:私は動的に私は同じAPIで取得します得点を表示する必要があるドロップダウン値に基づいて

<td> 
    <div class=""> 
     <select ng-if="question.MasterDataCategoryId != null" id="answer{{question.QuestionId}}" ng-model="question.MasterData" ng-init="question.MasterData;" class="form-control" style="width: 300px; white-space:pre-wrap;"> 
      <option selected="selected"></option> 
      <option ng-repeat="answer in answerData[question.MasterDataCategoryId]" value="{{answer.MasterData}}">{{answer.MasterData}}</option> 
     </select> 
     <input ng-if="question.MasterDataCategoryId == null" id="{{question.QuestionId}}" ng-model="question.MasterData" type="text" style="width: 300px;" name="question.QuestionId" class="form-control"> 
    </div> 
</td> 
<td> 
    <div class=""> 
     <span ng-if="question.MasterDataCategoryId != null">{{question.Score}}</span> 
     <select ng-if="question.MasterDataCategoryId == null" id="projectlist" class="form-control" required ng-model="scoring"> 
      <option selected="selected"></option> 
      <option ng-repeat="score in scoringDetails" value="{{score.Score}}"> 
       {{score.Score}} 
      </option> 
     </select> 
    </div> 
</td> 

これを実現する方法を教えてください。

$http.get(url) 
    .then(function(response) { 
     console.log(JSON.stringify(response)) 
     // set your scoring variable here 
     $scope.scoring = yourValue; // your value from response 
    }).error(function(error) { 
     console.log(JSON.stringify(error)) 
    }); 

答えて

0

次のようhttp GETまたはPOSTメソッドを使用して、その機能であなたのAPIを呼び出して、ご希望のドロップダウン&にng-change = "someFunction()"を使用することができます。コントローラ

でHTML

<select ng-change="scoreChange()" ng-model="dropvalue"> 
    <option></option>..... 
</select> 

<select ng-model="score"> 
    <option></option>..... 
</select> 

でfollwingコード

を想定

$scope.scoreChange = function(){ 
    $scope.score = desiredvalue; 
    //or you can call api and assign it here. 
} 
0

ドロップダウンngの変更ではスコアのドロップダウン値を変更fucntionを書く -

関連する問題