I have the following html:
<div>
<div>
<input type="text" placeholder="Search" ng-model="userSearch.firstname">
</div>
</div>
<div>
<div ng-repeat="user in users | filter:userSearch ">
<div>
{{user.firstname}} {{user.lastname}}
</div>
</div>
</div>
So, I have an input field in which users can enter and search all users in my list. Is there a way to apply an inline filter in ng-repeat based on what the user enters into the search input?
The current solution filters only the first name
I would like to filter out both the first and last name
I tried:
<div>
<div>
<input type="text" placeholder="Search" ng-model="userSearch">
</div>
</div>
<div>
<div ng-repeat="user in users | filter:{firstname: userSearch, lastname: userSearch} ">
<div>
{{user.firstname}} {{user.lastname}}
</div>
</div>
</div>
But I think this is AND not an or.
source
share