I'm trying to filter a list based on a model value entered in a text box.
For example:
var person={};
person.Id=1;
person.Name="Test 1";
person.PetName="Rest 1"
var persons=[];
persons.push(person);
person.Id=2;
person.Name="Test ds";
person.PetName="Rest sd";
persons.push(person);
The Persons array contains multiple individuals. On my HTML page, I have a search box.
<input type="text" ng-model="searchText" placeholder="search by Name and pet name"/>
<div ng-repeat="person in persons | filter : {$:searchText}">
<div>{{person.Name}}</div>
</div>
Scenario 1:
When I enter 2 in the text box, one result appears. However, I only want to filter by name and pet name.
Is there a way to achieve this without using a custom filter? Does the filter directive allow for OR conditions on properties?
Any help would be appreciated. Thank you.