将功能操作限制为用户操作的行

时间:2016-04-18 03:24:31

标签: javascript angularjs

我找不到将ng-change触发的操作限制为仅由用户操作的行的方法。因此,如果用户选择"联盟"在下拉列表1中,应该在"可用项目"上显示两个下拉菜单。柱。从顶部开始,您可以选择一项运动,选中后,下拉菜单应显示联赛选项。现在的问题是,桌子上的所有下拉都会被填充(你可以看到,如果你选择"联赛"在另一行的下拉列表中,联赛选项已经显示在你选择你的运动之前)。我需要的是将功能仅限于用户操作的行。

这是一个小提琴:

https://embed.plnkr.co/kAiLw40hUvnLk9jv86aj/

<div class="col-md-12 limitObjects">
 <h4>Limit Object: </h4>
  <div style="overflow: auto; max-height: 500px; height: 100%">
   <table border="0" class="table-bordered myTable" >
    <tbody>
     <tr ng-repeat="item in userMappings" ng-model="item">
      <td class="col-md-4">
        {{item.idsport}}, Game Type {{item.idgametype}}, {{item.name}} (Current limit {{item.value}}) {{item.mapped}}
      </td>
      <td class="col-md-3 mapType" style="padding-bottom: 25px; padding-left: 15px" >
       <h4>Mapping Type: <span style="font-size:0.8em">{{mapping.name}}</span> </h4> 
       <select ng-model="item.mapping" ng-change="which(item, $index, event)" ng-options="mapping.name for mapping in mappingType" se-change=''></select>
      </td>
      <td class="col-md-4" style="padding-bottom: 25px; padding-left: 10px">
       <h4>Available Items:</h4>
       <select ng-show="item.buau" ng-model="sport" ng-change="getID(sport, $index, $event); table($event)"  ng-options="sport.name for sport in sportsList"></select>
       <select ng-show="item.buau == false" ng-model="sportLeague" ng-change="getLeaguecategories(sportLeague, $index, $event)" ng-options="sportLeague.name for sportLeague in sportsList" style="float: left;"></select>
       <select ng-show="item.buau == false"  ng-model="selectedLeague" ng-change="getID(selectedLeague, $index)" ng-options="selectedLeague.name for selectedLeague in leagueList" ></select>
      </td>
      <td class="col-md-4" style="padding-bottom: 25px; padding-left: 15px">
       <h4>Subjects: </h4>
       <select ng-model="subject" ng-change="getsubjectID(subject, $index)" ng-options="subject.description for subject in limitSubject"></select>
      </td>
     </tr>
   </tbody>
  </table>
 </div>
</div>
<script>

 $scope.mappingType = [{name: "Sport"}, {name: "League"}, {name: "No Mapping"}];

 $scope.sportsList = [{id : 34, name : "[Default]"}, {id: 15, name : "Alpine Skiing"}, { id : 8,  name : "American Football" }, { id : 23,  name : "Australian Rules"}];

 $scope.getLeaguecategories = function($event){
    $scope.leagueList = [{"name": "NFL"}, {"name": "NCAA"}, {"name": "All others"}];
 }

 $scope.userMappings =[{"id":"1","idgametype":"81","idsport":"NFL","mapped":"0","name":"Side","online":"1","profilelimitkeyid":"1","value":"3000"},{"id":"2","idgametype":"81","idsport":"NFL","mapped":"4","name":"Total","online":"1","profilelimitkeyid":"1","value":"3000"},{"id":"3","idgametype":"81","idsport":"NFL","mapped":"0","name":"IfBets","online":"1","profilelimitkeyid":"1","value":"500"},{"id":"4","idgametype":"81","idsport":"NFL","mapped":"0","name":"MoneyLine","online":"1","profilelimitkeyid":"1","value":"2000"},{"id":"5","idgametype":"81","idsport":"NFL","mapped":"1","name":"Parlays","online":"1","profilelimitkeyid":"1","value":"700"},{"id":"6","idgametype":"81","idsport":"NFL","mapped":"0","name":"Related","online":"1","profilelimitkeyid":"1","value":"0"},{"id":"7","idgametype":"81","idsport":"NFL","mapped":"0","name":"Reverses","online":"1","profilelimitkeyid":"1","value":"500"},{"id":"8","idgametype":"81","idsport":"NFL","mapped":"2","name":"Teasers","online":"1","profilelimitkeyid":"1","value":"0"}];



$scope.which = function( item, index ) {
  if ( item.mapping.name === "Sport" ){
       item.buau = true;
  } else if ( item.mapping.name === "League" ) {
       item.buau = false;
  } else if ( item.mapping.name === "No Mapping" ){

  }
 }

0 个答案:

没有答案