title: String comparison in AngularJS
body: <p>I'm trying to compare two strings in AngularJS, and I've seen examples online. As I understand it, you can use angular.equals(str1, str2), you can use ===, you can use == if you're sure that both are strings...</p>
  
  <p>I've tried all three, but I don't get the result. Something must be wrong in what I've done, but I don't know what it is. </p>
  
  <p>When I run the code, the inc1() function is called. The first alert appears "inc1 called". But the second alert, "Inside for loop", executes only once. It should execute twice, shouldn't it?</p>
  
  <p>And the alert inside of the if(condition) does not execute at all. If I remove the 'if' block, then the alert "Inside for loop" runs two times.</p>
  
  <p>I'd be much obliged if someone could tell me what I'm doing wrong here. I've used angular.equals(), === and ==, but the same thing happens everytime. </p>
  
  <p>This is how the HTML and AngularJS codes go:</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;a class="tab-item" ng-repeat = "x in items" ng-if="name==x.names" ng-click="inc1(name)"&gt;
    &lt;i class="icon ion-thumbsup"&gt;&lt;/i&gt;
    Like
   &lt;/a&gt; 
  </code></pre>
  
  <p>AngularJS:</p>
  
  <pre><code>$rootScope.items = [
  { id: 1, names: 'Dolphin', image: 'dolphin.jpg'}, { id: 2, names: 'Donkey', image: 'donkey.jpg'}];
  
  $scope.inc1 = function(name) {
  
  alert("inc1 called");
  for(var i=0;i&lt;$rootScope.items.length;i++)
  {
      alert("Inside for loop");
      if (name === $rootScope.items.names[i])
          {
          alert("If condition satisfied");
          }
  }
  }
  </code></pre>
  
  <p>//Say, name is 'Dolphin'</p>