2016-08-12 7 views
0

年値の変更時に、[Make]ドロップダウンのオプションを変更したいが、他のコントロールのオプションを更新する方法がない。角度変更、他の選択コントロールのオプションを更新する方法

以下は私のフォームを持つプランカーです。 https://plnkr.co/edit/aV65Nab9U9I6YlK2g4sY?p=preview
api.phpはサーバーの応答です。これらのオプションは、[変更を作成する]に表示する必要があります。あなたのコントローラでこの機能を配置する必要があり

autoQuoteCtrl.js

$scope.updateMakeList = function(){ 
} 

index.htmlを

<div class="row"> 
        <div class="form-group"> 
         <label class="col-sm-5 control-label" for="PC">{{questions[$state.current.name].VehicleYear.QuestionData._text}}</label> 
         <div class="col-sm-6"> 
          <select ng-change="updateMakeList" custom-required="true" ng-options="ans._value as ans._promptText for ans in questions[$state.current.name].VehicleYear.QuestionData._answerOptions" ng-model="answers.VehicleYear" ng-required="queObj._required" class="form-control {{queObj._pageAttributes.cssclass}}" name="{{questions[$state.current.name].VehicleYear.QuestionData._attributeName}}" id="{{questions[$state.current.name].VehicleYear.QuestionData._attributeName}}" data-que-obj="questions[$state.current.name].VehicleYear.QuestionData" select-control-dir setMake custom-required></select> 
         </div>      
        </div> 
        <span class="form-error" ng-show="submitted && DTOstep1.VehicleYear.$error.required">This field is required.</span> 
       </div> 

答えて

1

-

$scope.updateMakeList = function(name) 
        {     
// Your logic to change value in Make dropdown 
$scope.questions[name].VehicleMake.QuestionData._answerOptions = [{'_value':"test",'_promptText':"Test"}]; 
        } 

そして、あなたのHTMLを更新します(年選択ボックス) -

  <div class="form-group"> 
       <label class="col-sm-5 control-label" for="PC">{{questions[$state.current.name].VehicleYear.QuestionData._text}}</label> 
       <div class="col-sm-6"> 
        <select ng-change="updateMakeList($state.current.name)" custom-required="true" ng-options="ans._value as ans._promptText for ans in questions[$state.current.name].VehicleYear.QuestionData._answerOptions" ng-model="answers.VehicleYear" ng-required="queObj._required" class="form-control {{queObj._pageAttributes.cssclass}}" name="{{questions[$state.current.name].VehicleYear.QuestionData._attributeName}}" id="{{questions[$state.current.name].VehicleYear.QuestionData._attributeName}}" data-que-obj="questions[$state.current.name].VehicleYear.QuestionData" select-control-dir setMake custom-required></select> 
       </div>      
      </div> 
関連する問題