title: Filter by object property in Angularjs
body: <p>I'm trying to create a simple filter in AngularJS that will filter through my JSON: first_name, last_name and phone_number, but i'm not sure how to reference specific properties in my JSON to create the HTML dropdown.</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;div ng-app="instantsearch"&gt;
      &lt;div ng-controller="instantSearchCtrl"&gt;
              &lt;input type="text" class="search" ng-model="searchString" placeholder="Enter your search terms" /&gt;
  
              &lt;select class="data-ctrl" &gt;
                &lt;option ng-repeat="i in items | filter:searchString" value="@{{ i.clientid }}"&gt;@{{ i.first_name }} @{{ i.last_name }}&lt;/option&gt;
              &lt;/select&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>JSON</p>
  
  <pre><code>{"clients":
  [
  {"clientid":"1","first_name":"myfirst","last_name":"client","phone_number":"","email":""},
  {"clientid":"2","first_name":"mysecond","last_name":"client","phone_number":"","email":""},
  {"clientid":"3","first_name":"mythird","last_name":"client","phone_number":"","email":""},
  {"clientid":"4","first_name":"myfourth","last_name":"client","phone_number":"","email":""}
  ]}
  </code></pre>
  
  <p>JS</p>
  
  <pre><code>var app = angular.module('instantsearch',[]);
  
  app.controller('instantSearchCtrl',function($scope,$http){
      $http.get('/api/clients').success(function(data, status, headers, config) {
          $scope.items = data.data;
      }).error(function(data, status, headers, config) {
          console.log("No data found..");
    });
  });
  
  
  app.filter('searchFor', function(){
      return function(arr, searchString){
          if(!searchString){
              return arr;
          }
          var result = [];
          searchString = searchString.toLowerCase();
          angular.forEach(arr, function(item){
              if(item.first_name.toLowerCase().indexOf(searchString) !== -1){
              result.push(item);
          }
          });
          return result;
      };
  });         
  </code></pre>