title: What is the value of an empty text input box?
body: <p>I am trying to implement a search box. The following is the code (both HTML and JS)</p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;form&gt;
      &lt;input type="text" ng-model="searchVar" class="searchbox"&gt;
      &lt;input type="button" value="Search" ng-click="Search()" class="button"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>JS</strong></p>
  
  <pre><code>var Search = function() {
  
  /* code to implement the table content loading part */    
  //The following is what I have to filter out the table contents based on input in the text field
  
       if (($scope.searchVar) &amp;&amp; (tableContent[i].indexOf($scope.searchVar) !== -1)) {
            ItemsToDisplay.push(tableContent[i])
       }  
      //Call function to load table
  }
  </code></pre>
  
  <p>What is happening is that, if I enter some string into the input text field, the search algorithm works fine and only the relevant items are displayed. However, if I clear the contents of the search box and click on Search button, nothing is displayed in the table. That is, when the text field is cleared and clicked on the search button, it is as if ItemsToDisplay is empty and the if condition fails.</p>
  
  <p>Can someone explain why this is the case? And how I can solve this?</p>