title: TypeError: Cannot read property 'indexOf' of undefined for $scope.search angular bootstrap
body: <p>I am trying to write a function which filters rows based on couple of properties. When I run the code, the list is not getting displayed and there's an error stating "TypeError: Cannot read property 'name' of undefined ". I am trying to search on columns name and location. Here's my html code</p>
  
  <pre><code>&lt;tbody ng-if="routerList.length"&gt;
  &lt;tr ng-repeat="router in routerList | orderBy: rule|filter : search | limitTo:5:5*(naviagtion.currentPage-1) "&gt;
      &lt;td&gt;&lt;span&gt;{{router.routerId}}&lt;/span&gt;&lt;/td&gt;
      &lt;td&gt;&lt;span&gt;{{router.name}}&lt;/span&gt;&lt;/td&gt;
      &lt;td&gt;&lt;span&gt;{{router.macAddr}}&lt;/span&gt;&lt;/td&gt;
      &lt;td&gt;&lt;span&gt;{{router.primaryIP}}&lt;/span&gt;&lt;/td&gt;
      &lt;td&gt;&lt;span&gt;{{router.status}}&lt;/span&gt;&lt;/td&gt;
      &lt;td&gt;&lt;span&gt;{{router.location}}&lt;/span&gt;&lt;/td&gt; 
  
  &lt;/tr&gt;
  &lt;/tbody&gt;
  </code></pre>
  
  <p>In my controller, I have a function search</p>
  
  <pre><code>$scope.search = function(item){
      if($rootScope.naviagtion.searchText == undefined){
          return true;
      }else{
          if(item.router.name.indexOf($rootScope.naviagtion.searchText) != -1 || item.router.location.indexOf($rootScope.naviagtion.searchText) != -1 ){
              return true;
          }
      }
      return false;
  }
  </code></pre>
  
  <p>Can someone tell me what's wrong?</p>