Answers for "angular array filter multiple conditions"

1

javascript filter array multiple conditions

var filter = {
  address: 'England',
  name: 'Mark'
};
var users = [{
    name: 'John',
    email: '[email protected]',
    age: 25,
    address: 'USA'
  },
  {
    name: 'Tom',
    email: '[email protected]',
    age: 35,
    address: 'England'
  },
  {
    name: 'Mark',
    email: '[email protected]',
    age: 28,
    address: 'England'
  }
];


users= users.filter(function(item) {
  for (var key in filter) {
    if (item[key] === undefined || item[key] != filter[key])
      return false;
  }
  return true;
});

console.log(users)
Posted by: Guest on July-01-2021
0

Is it possible to filter with multiple condition in angularjs?

You should create a custom filter. By evaluating multiple conditions in one filter it will gain 'performance'.

$scope.filterData = function (item) {
    return (item.SECURITYCLASS === 90 || item.SECURITYCLASS === 93);
}
<div ng-repeat="item in data | filter:filterData">
    {{::item}}
</div>
//demo
http://plnkr.co/edit/aDx3SfXaTqEqrlMxIzgd
Posted by: Guest on September-08-2021

Code answers related to "angular array filter multiple conditions"

Code answers related to "Javascript"

Browse Popular Code Answers by Language