in my code iam using custom filter for filtering based on gender(male female).But when i click male value female values are also displayed since female value contains male in it. And when i click female it filters successfully. This is my code.
app.filter('myFilter', function() {
return function(items, filterby, filterbyc) {
var filtered = [];
var filtermatch = new RegExp(filterby, 'i');
angular.forEach(items, function(value) {
if ((filtermatch.test(value.gender))) {
filtered.push(value);
}
return filtered;
})
};
});
so what function other than .test can i use to compare the values so that when comparing male and female values it wont take male from female.
This is my html code
<ul id="result">
<li ng-repeat="x in details | myFilter:filterby">
<div>Name :{{x.name }}</div>
<div>Address : {{x.address }}</div>
<div>Gender: {{x.gender}}</div>
<div>Country: {{x.country }}</div>
<div>Agree: {{x.agree }}</div>
</li>
</ul>