Filtering an array of objects on 1 property not limited to start of text
<p>I'm trying to combine lodash with ngMaterial and md-autocomplete. </p>

<p>I have a collection of user objects in an array: </p>

<pre><code>var User.collection = [
  { 'user': 'fred',   'age': 48 },
  { 'user': 'barney', 'age': 34 },
  { 'user': 'fred',   'age': 42 },
  { 'user': 'barney', 'age': 36 }
];
</code></pre>

<p>I am trying to filter this list to return only the ones matching the search query for example </p>

<p><code>var query = "fr"</code></p>

<p>I get the filter working with this controller function: </p>

<pre><code>collectionFilter: function(query) {
    var lowercaseQuery = angular.lowercase(query);
    return _.filter(User.collection, function(obj) {
        return (angular.lowercase(obj.name).indexOf(lowercaseQuery) === 0)
    })
}
</code></pre>

<p>Issue with this is that I won't get any results if I star typing the middle of the name like "rne". </p>