title: Variable change in controller not being reflected on UI - AngularJS
body: <p>I am changing a variable in my controller by calling a function. The variable 
  isSameTaxonomyElements is bind with an element in UI. But it is being reflected on UI.</p>
  
  <pre><code>$scope.validateAddElementButton = function (name, label) {          
              for (var i = 0; i &lt; $scope.elements.length; i++) {             
                  if (name === $scope.elements[i].name || label === $scope.elements[i].label) {
                    $scope.isSameTaxonomyElements = true;      
                    break; 
                  } else {
                    $scope.isSameTaxonomyElements = false;                
                  }             
              }          
          }
  </code></pre>
  
  <p>This is my UI.</p>
  
  <pre><code> &lt;div ng-show="isSameTaxonomyElements"&gt;
                  &lt;div class="col-lg-6 float-left" &gt;
                    &lt;p class="alert-message"&gt;No two elements should have same label or name.&lt;/p&gt;
                  &lt;/div&gt;
                &lt;/div&gt;
  </code></pre>
  
  <p>I have also tried adding $timeout, $apply etc, but still not working.</p>