title: Cannot read property 'toLowerCase' of undefined angularjs
body: <p>I'm trying to make a search function in my angularjs "webapp". When I search in products all works fine, but when I change everything so that it searches into users, i get an error Cannot read property 'toLowerCase' of undefined. </p>
  
  <p>Here's my js:</p>
  
  <pre><code>    return function(arr, searchString){
      if(!searchString){
          return arr;
      }
      var result = [];
      searchString = searchString.toLowerCase();
      angular.forEach(arr, function(item){
          if(item.title.toLowerCase().indexOf(searchString) !== -1){
              result.push(item);
          }
      });
      return result;
  };
  });
  </code></pre>
  
  <p>And here's the html that's calling it:</p>
  
  <pre><code>&lt;div ng-controller="userCtrl" class="container-app"&gt;
  &lt;div class="bar"&gt;
      &lt;input type="text" class="search" ng-model="searchString" placeholder="Enter your search terms" /&gt;
  &lt;/div&gt;
  &lt;div class="searchResultsText"&gt;
      &lt;h2&gt;Zoekresultaten: &lt;/h2&gt;
  &lt;/div&gt;
  &lt;div class="searchResults" ng-repeat="user in users | searchFor:searchString"&gt;
      &lt;a class="normal" href="#"&gt;{{user.name}}&lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p></p>
  
  <p>it does show me the list of users, just as soon as I start typing in the search bar it gives me the error. </p>
  
  <p>when I use the exact same function, with a different controller it works. Here are the 2 controllers:</p>
  
  <pre><code>app.controller('customersCtrl', function ($scope, $http) {
  $http.get(apiUrl + "product/list")
      .success(function (response) {
          $scope.products = response;
      });
  });
  
  app.controller('userCtrl', function ($scope, $http) {
  $http.get(apiUrl + "user/list")
      .success(function (response) {
          $scope.users = response;
      });
  });
  </code></pre>
  
  <p>so basically customerCtrl works fine, but when i change values to userCtrl it stops working. </p>
  
  <p>any suggestions?</p>