2016-11-04 6 views
0

以下は私のHTMLです データベースに以下のパラメータを渡したいと思います。私は単純なテキスト値を渡すことができます。オプションタグに必須パラメータを渡すことはできません。私はポストコールを呼び出すときに、動的なオプションの選択に、そのホストテーブルからホストのすべてのデータを送信しているが、私は、ホスト名のみを渡したい選択したオプションから選択した「オプション」データのみを渡す必要があります

<form name="main" novalidate> 
    <div class="table-responsive" ng-show="visible8"> 
    <h4>Conditions</h4> 
    <!-- <button type="button" class="btn btn-primary" ng-click="addCondition()">Apply</button> --> 
    <button type="button" class="btn btn-primary" ng-click="addNewCondition()">Add Condition</button> 
    <button type="button" class="btn btn-primary" ng-click="removeCondition()">Remove Condition</button> 
    <button type="button" class="btn btn-primary" ng-click="cancel()">Cancel</button> 
    <button class="btn btn-primary pull-right" ng-click="showAction()" ng-disabled!="">Next Step</button>         
    <button class="btn btn-primary pull-right" ng-click="showBackRules()" ng-disabled!="">Back</button>         
    <br> 
    <br> 
    <fieldset data-ng-repeat="choice in choices"> 
     <table class="table table-bordered" id="table" > 
     <thead> 
      <tr> 
      <th>Parameter</th> 
      <th>Value</th> 
      <th>Comment</th> 
      </tr> 
     </thead> 
     <tbody> 
      <tr> 
      <th>Select Condition Type</th> 
      <td> 
       <select name="option" class="form-control" ng-model="mySelect" ng-disabled="readonly" ng-change="selectedOption(mySelect);displayParam()"> 
       <option ng-repeat="type in model.condition_type" value= "{{ type.NAME }}" >{{ type.NAME }}</option> 
       </select> 
      </td> 
      <td>Select Condition</td> 
      </tr> 
      <tr ng-repeat="child in model.rule_key[$index]"> 
      <!-- <td ng-repeat="child in parent_rule"> 
       {{ child.KEY_NAME }} 
       </td> 

       </tr> --> 
      <th> {{ child.KEY_NAME }} </th> 
      <td> 
       <input type="text" class="form-control" ng-model="rule1.conditions.Value" 
       name="child.KEY_NAME" ng-if="child.KEY_NAME != 'Host' && child.KEY_NAME != 'Sensor' && child.KEY_NAME != 'Field' && child.KEY_NAME != 'Operator'" required/> 
       <span style="color:red" ng-show="main.AssetURL.$error.required ">Service name</span> 
       <select name="child.KEY_NAME" class="form-control" 
       ng-options="host.Name for host in hosts track by host.id" 
       ng-model="rule1.conditions.Host" ng-if="child.KEY_NAME != 'Operator' && child.KEY_NAME != 'Sensor' && child.KEY_NAME != 'Field' && child.KEY_NAME != 'Value'" ng-disabled="readonly"> 
       <option value=""></option> 
       </select> 
       <select name="child.KEY_NAME" class="form-control" 
       ng-options="sensor.SnsName for sensor in model.sensors" 
       ng-model="rule1.conditions.Sensor" ng-if="child.KEY_NAME != 'Operator' && child.KEY_NAME != 'Host' && child.KEY_NAME != 'Field' && child.KEY_NAME != 'Value'" ng-disabled="readonly"> 
       <option value=""></option> 
       </select> 
       <select name="child.KEY_NAME" class="form-control" ng-model="rule1.conditions.Operator" 
       ng-if="child.KEY_NAME != 'Host' && child.KEY_NAME != 'Sensor' && child.KEY_NAME != 'Field' && child.KEY_NAME != 'Value'" required> 
       <option value="greater">></option> 
       <option value="smaller"><</option> 
       <option value="equal">=</option> 
       </select> 
       <span style="color:red" ng-show="main.CaptLen.$error.required ">Select ServiceType</span> 
       <select name="child.KEY_NAME" ng-if="child.KEY_NAME != 'Host' && child.KEY_NAME != 'Sensor' && child.KEY_NAME != 'Operator' && child.KEY_NAME != 'Value'" class="form-control" ng-model="rule1.conditions.Field" ng-disabled="readonly" > 
       <option ng-repeat="field in ruleField[0].columns track by $index" value= "{{ field }}" >{{ field }}</option> 
       </select> 
      </td> 
      <td> {{ child.DESCRIPTION }} </td> 
      </tr> 
     </tbody> 
     </table> 
    </fieldset> 
    </div> 
</form> 

それぞれのJS

$scope.saveAll = function(rule1) { 
    console.log(rule1); 
    var newaction = JSON.stringify(rule1.actions); 
    console.log("newaction", newaction); 
    var newcondition = JSON.stringify(rule1.conditions); 
    console.log("newcondition", newcondition); 
    var newrule = { 
     ruleName: rule1.ruleName, 
     ruleDesc: rule1.ruleDesc, 
     RULE_TYPE: rule1.RULE_TYPE, 
     CONDITION_LIST: newcondition, 
     ACTION_LIST: newaction, 
    }; 
    console.log("newrule", newrule); 

    $http.post("/nodejs/addRule", newrule) 
     .success(function(data) { 
      console.log("New rule", data); 
      $scope.model.rule_list.push(data[0]); 
      $scope.len = $scope.model.rule_list.length; 
     }) 
     .error(function(err) { 
      alert("error"); 
      //console.log(err); 
     }); 
    // $scope.check(); 
    $scope.visible13 = false; 
    $scope.visible2 = true; 
    $scope.visible3 = true; 
    $scope.visible7 = true; 
    $scope.rule1 = {}; 
}; 

output Input screen

+0

デモコードを作成してください。 –

+0

申し訳ありませんが、私はあなたを理解していません –

+0

fiddleまたはplnkrでデモを作成してください –

答えて

0

あなたはこのようにNG-オプションの構文を使用して、NG-モデルにホスト名のみをバインドする必要があります。

ng-options="host.Name as host.Name for host in hosts track by host.id" 
関連する問題