What I am trying to do is search by multiple fields of a repeat in combination. The issue is when I search by query.$
model I can't search from multiple fields.
What I'm looking for is to search for 1234 + Street Name
<input ng-keypress="searching()" type="text" ng-model="query.$" placeholder="Search" />
<li ng-repeat="item in (filteredItems = (items| filter:query))">
{{item.address.streetNumber}} {{item.address.streetName}}
</li>
I found a set of filters which I thought would work but not sure I'm using this right.
filterBy: ['item.address.streetNumber' + 'item.address.streetName']: query
Any help appreciated. Here is what I have done. http://plnkr.co/edit/75nGxVgqL3lJVFlGyZMY?p=preview
using a predicate function is one way, see: http://ngtutorial.com/learn/filter.html#/_tblcontents_20
update
please tell me if that example does not explain it properly, thanks.
Update, add example
return 'true' if you wanted the item.
myApp.controller('MyCtrl', ['$scope', function($scope) {
$scope.predfn = function(v) {
return v.name == '123' || v.phone == 'Fake Street';
};
...
<tr ng-repeat="friendObj in friends | filter:predfn">
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.