title: Check duplicate values between multiple inputs and show error message
body: <p>I have list of inputs from an array created via ng-repeat. I want to check if there are any duplicated values in them. If any duplicated value found it shows an error message.
  I found what I was wanting in this <strong><a href="http://jsfiddle.net/pkhxkozp/8/" rel="nofollow">JS FIDDLE</a></strong></p>
  
  <pre><code>&lt;tr ng-repeat="person in persons"&gt;
              &lt;td&gt;
                  &lt;ng-form name="personForm"&gt;
                   &lt;div ng-class="{ 'has-error' : 
                      personForm.personName.$invalid }"&gt;
                      &lt;input type='text'
                      name="personName"
                      ng-class="empty"
                      ng-model="person.name"
                      ng-change="verifyDuplicate()"/&gt;
                     &lt;/div&gt;
                   &lt;/ng-form&gt;
                  &lt;div class='error'
                      ng-if='person.isDuplicate'&gt;
                      Duplicate.
                  &lt;/div&gt;
              &lt;/td&gt;
  </code></pre>
  
  <h2>            </h2>
  
  <pre><code>$scope.verifyDuplicate = function() {
          var sorted, i;
  
          sorted = $scope.persons.concat().sort(function (a, b) {
              if (a.name &gt; b.name) return 1;
              if (a.name &lt; b.name) return -1;
              return 0;
          });
          for(i = 0; i &lt; $scope.persons.length; i++) {
              sorted[i].isDuplicate = ((sorted[i-1] &amp;&amp; sorted[i-1].name == sorted[i].name) || (sorted[i+1] &amp;&amp; sorted[i+1].name == sorted[i].name));
          }
      };
  </code></pre>
  
  <p>So I implemented this in my <strong><a href="http://plnkr.co/edit/ORkXFzgrbemle3SGhrMP?p=preview" rel="nofollow">Plunker</a></strong></p>
  
  <pre><code>&lt;div ng-repeat="item in csTagGrp"&gt;
      &lt;div ng-repeat="person in item.csTags"&gt;
        &lt;ng-form name="personForm"&gt;
          &lt;div ng-class="{ 'has-error' : 
                      personForm.personName.$invalid }"&gt;
            &lt;input type='text' name="personName" ng-class="empty" ng-model="person.keys" ng-change="verifyDuplicate()" /&gt;
          &lt;/div&gt;
        &lt;/ng-form&gt;
        &lt;div class='error' ng-if='person.isDuplicate'&gt;
          Duplicate.
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  
  
  $scope.verifyDuplicate = function() {
      var sorted, i;
  
      sorted = $scope.csTagGrp.csTags.concat().sort(function(a, b) {
        if (a.name &gt; b.name) return 1;
        if (a.name &lt; b.name) return -1;
        return 0;
      });
      for (i = 0; i &lt; $scope.csTagGrp.csTags.length; i++) {
        sorted[i].isDuplicate = ((sorted[i - 1] &amp;&amp; sorted[i - 1].name == sorted[i].name) || (sorted[i + 1] &amp;&amp; sorted[i + 1].name == sorted[i].name));
      }
    };
  </code></pre>
  
  <p>But looks like it's not working for some reason. I am using a different nested array of objects here.What I am doing wrong here ? </p>
  
  <p>Thanks in advance.  </p>