title: Filtering by array within ng-options
body: <p>I would like to filter my list of objects in the <code>ng-options</code> by those that match a certain condition within the object.</p>
  
  <p>For example I have data like this:</p>
  
  <pre><code>{
          id:1,
          type:"Type A",
          name:"loc 1",
          items:[
              {id:1, name:"item 1"},
              {id:2, name:"item 2"},
              {id:3, name:"item 3"},
          ]
      },
  </code></pre>
  
  <p>My select looks like this </p>
  
  <pre><code>&lt;select ng-model="test" ng-options="location as (location.name + ' ' + location.items.length + ' items') group by location.type for location in locations | filter:{items.length:filterBy.itemId}"&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>The example below works by filtering the list by the number of items in the array, but what I want to do is to filter the list by those that have a criteria such as all objects that have an item with id=1.</p>
  
  <p>Here is a working fiddle with the above.</p>
  
  <p><a href="http://jsfiddle.net/declanmcd/qyqgv6z0/" rel="nofollow">fiddle example</a></p>
  
  <p>What I would like/expect (in pseudo) something like:</p>
  
  <pre><code>ng-options="location as (location.name + ' ' + location.items.length + ' items') group by location.type for location in locations | filter:{items{id:filterBy.itemId}}"
  </code></pre>
  
  <p>Is it even possible? </p>
  
  <p><strong>Update</strong>: The fiddle above has been updated with the code in the answer from @Marcos Sandrini below in case anyone needs it.</p>