Am looking for angularjs multiple condition filter like this arr in array | filter:filters.search | filter:{company: selectedName} | filter:{voucher_type: both }
It working but not filtering all condition am pasting my full code here . filter:{company: selectedName} | filter:{voucher_type: both }
this filter step is wrong in my code.@Thank you for response
<html >
<head>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"/>
<title>search</title>
</head>
<body>
<div ng-app="app" ng-controller="mainCtrl">
<div><select ng-model="selectedName" ng-options="x for x in names">
</select>
</div>
<input type="text" ng-model="both">
<div>Search by Name: <input type="text" ng-model="filters.search"></div>
<div ng-repeat="arr in array | filter:filters.search | filter:{company: selectedName} | filter:{voucher_type: both } ">
<span ng-bind="arr.name"></span>
</div>
</div>
<script type="text/javascript" src="js/angular.min.js"></script>
<script src="js/ui-bootstrap-tpls-0.9.0.js"></script>
<script type="text/javascript">
var app = angular.module('app', []);
app.controller('mainCtrl', function($scope) {
$scope.names = ["x", "y"];
$scope.filters = {
x: false,
company: '',
search: ''
};
$scope.actions = {
updateyCompany: function () {
if($scope.filters.y) {
$scope.filters.company = 'y';
} else {
$scope.filters.company = '';
}
}
};
$scope.both ="z";
$scope.array = [
{name: 'Tobias', lname: 'TLname', company: 'x'},
{name: 'Jeff', lname: 'JLname', company: 'x'},
{name: 'Brian', lname: 'BLname', company: 'x'},
{name: 'Igor', lname: 'ILname', company: 'y'},
{name: 'James', lname: 'JLname', company: 'z'},
{name: 'Brad', lname: 'BLname', company: 'y'},
{name: 'Basil', lname: 'Basil', company: 'z'},
];
});
</script>
</body>
</html>
Field voucher_type is not available in your array so, it can not find out. Please add this field and make filter working Properly. !!!
am make some changes it work fine now filter:valFilter
filter is changed and new function is added
$scope.valFilter = function (arr) {
return (arr.company == "z" || arr.company == $scope.selectedName);
}
Thank you all