Angularjs 交叉检查输入复选框值与角度方向的数组

Angularjs 交叉检查输入复选框值与角度方向的数组,angularjs,ionic-framework,Angularjs,Ionic Framework,我的控制器中有如下数组: $scope.word_pair = [ {'word':'Carla', 'pair':'Lion'}, {'word':'Sophie', 'pair':'Lotta'}, {'word':'Jannes', 'pair':'Stubbi'}, {'word':'Martin', 'pair':'Wolle'}, {'word':'Flo', 'pair':'Ign'}, {'word':'Rere', 'pair':'Rose'},

我的控制器中有如下数组:

$scope.word_pair = [

  {'word':'Carla', 'pair':'Lion'},
  {'word':'Sophie', 'pair':'Lotta'},
  {'word':'Jannes', 'pair':'Stubbi'},
  {'word':'Martin', 'pair':'Wolle'},
  {'word':'Flo', 'pair':'Ign'},
  {'word':'Rere', 'pair':'Rose'},
  {'word':'Jean', 'pair':'Tamara'},
  {'word':'Memo', 'pair':'Elk'},
  {'word':'Nila', 'pair':'Naph'}

  ]
在我的HTML模板上,我有两个输入列表,其中我应该输入上面数组中的几个组合,如果组合正确,那么将有一个绿色的复选标记

到目前为止,我的HTML如下所示:

<!-- Level 2 Enter view for words for corresponding pairs --> 
      <div class="col col-50" ng-if="enterTextViewLeft">enterTextViewLeft
        <ion-list>
          <ion-item ng-repeat="item in randomWord_pair" id="list_two">
            <input placeholder="Type here" ng-model="word" type="text" ng-change="leftPartnerCheck(word,item.pair)">
            <div ng-show="showPartner[word]" align="right"><i class="ion-checkmark myCheckmark"></i></div>
          </ion-item>
        </ion-list>
      </div>

<!-- Level 1 Enter view for pairs for corresponding words -->
      <div class="col col-50" ng-if="enterTextViewRight">enterTextViewRight
        <ion-list>
          <ion-item ng-repeat="item in randomWord_pair" id="list_two">
            <input placeholder="Type here" ng-model="pair" type="text" ng-change="rightPartnerCheck(pair,item.word)">
            <div ng-show="showPartner[pair]" align="right"><i class="ion-checkmark myCheckmark"></i></div>
          </ion-item>
        </ion-list>
      </div>

我如何实现这样的逻辑(针对两个输入列表并检查数组中的现有组合)或将其合并到现有逻辑中?

我创建了一个示例来说明如何执行此操作,我将在下面解释:

HTML:


AngularJS:

$scope.word_pair = [
  {'word':'Carla', 'pair':'Lion'},
  {'word':'Sophie', 'pair':'Lotta'},
  {'word':'Jannes', 'pair':'Stubbi'},
  {'word':'Martin', 'pair':'Wolle'},
  {'word':'Flo', 'pair':'Ign'},
  {'word':'Rere', 'pair':'Rose'},
  {'word':'Jean', 'pair':'Tamara'},
  {'word':'Memo', 'pair':'Elk'},
  {'word':'Nila', 'pair':'Naph'}
 ];

$scope.guesses = [];
 $scope.otherguesses = [];

$scope.check = function(word, pair) {
   for(var i=0; i<$scope.word_pair.length; i++) {
     if($scope.word_pair[i].word == word && $scope.word_pair[i].pair == pair) {
       return true;
     }
   }
}
$scope.word\u对=[
{'word':'Carla','pair':'Lion'},
{'word':'Sophie','pair':'Lotta'},
{'word':'Jannes','pair':'Stubbi'},
{'word':'Martin','pair':'Wolle'},
{'word':'Flo','pair':'Ign'},
{'word':'Rere','pair':'Rose'},
{'word':'Jean','pair':'Tamara'},
{'word':'Memo','pair':'Elk'},
{'word':'Nila','pair':'Naph'}
];
$scope.guesses=[];
$scope.otherguesses=[];
$scope.check=函数(字、对){

对于(var i=0;i您的问题是什么?是的,有点遗漏了!我更新了问题。基本上我如何实现这样的逻辑?不!我想我的问题不太清楚(请参见上面括号中的屏幕截图)在左边的列表输入框中,玩家应该能够填写单词对中的任何“单词”,在右边,可以填写单词对中的任何“单词”(顺序无关紧要),如果组合正确,请勾选!我的工作plunkr:但是我有一个问题..我现有的代码的任何部分是否可以被使用/修改以合并您的逻辑,整体功能几乎是相似的?如果您愿意,您可以看看我的Plunker吗?只需复制我的函数和
ng model
声明。您应该吗实施起来并不难。
<div ng-controller="MyCtrl">
  <table>
    <tr ng-repeat="w in word_pair">
      <td> <input type="text" ng-model="guesses[$index]"> </td>
      <td> <input type="text" ng-model="otherguesses[$index]"> </div> </td>
      <td> <input type="checkbox" ng-checked="check(guesses[$index], otherguesses[$index])" disabled> </td>
    </tr>
  </table>
</div>
$scope.word_pair = [
  {'word':'Carla', 'pair':'Lion'},
  {'word':'Sophie', 'pair':'Lotta'},
  {'word':'Jannes', 'pair':'Stubbi'},
  {'word':'Martin', 'pair':'Wolle'},
  {'word':'Flo', 'pair':'Ign'},
  {'word':'Rere', 'pair':'Rose'},
  {'word':'Jean', 'pair':'Tamara'},
  {'word':'Memo', 'pair':'Elk'},
  {'word':'Nila', 'pair':'Naph'}
 ];

$scope.guesses = [];
 $scope.otherguesses = [];

$scope.check = function(word, pair) {
   for(var i=0; i<$scope.word_pair.length; i++) {
     if($scope.word_pair[i].word == word && $scope.word_pair[i].pair == pair) {
       return true;
     }
   }
}