我尝试过滤两个值,例如| filter:{voucher_type: selectedName } | filter:{voucher_type: both }
这两个都是" B"和selectedName" P或R"。下面的代码只能使用一个过滤器。
我想将这两个过滤器值组合在一起并显示结果,如voucher_type B + P(Or)R。
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"/>
<title>search</title>
</head>
<body>
<div class="row">
<div class="container">
<div class="col-sm-9">
<div ng-app="myApp">
<script type="text/ng-template" id="search">
<a>
<span bind-html-unsafe="match.label | typeaheadHighlight:query"></span>
<i> {{match.model.sub_name}} -({{match.model.group_name}}) </i>
</a>
</script>
<form class="form-search" ng-controller="autocompleteController">
Selected Ledger: {{selectedLedgers}} <br>
<br>
<!-- typeahead="c as c.ledger_id + '-' + c.ledger_name + ' <i>(' +c.group_name + ')</i>'-->
<input type="text" ng-model="both"></p>
<div>select voucher :<select ng-model="selectedName" ng-options="x for x in names">
</select>
</diV>
<input type="text" ng-model="selectedLedgers" placeholder="Search Ledger" typeahead="c as c.ledger_id + '-'+ c.ledger_name for c in producers | filter:$viewValue| limitTo:20 | filter:{voucher_type: selectedName1 } | filter:{voucher_type: both }" typeahead-min-length='2' typeahead-on-select='onSelectPart($item, $model, $label)' typeahead-template-url="search" class="form-control" style="width:350px;">
<i class="icon-search nav-search-icon"></i>
</form>
</div>
</div>
</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('myApp', ['ui.bootstrap']);
app.controller('autocompleteController', function($scope, $http) {
$http.get("getLedgers.php").success(function(data){
$scope.producers = data;
});
$scope.names = ["P", "R"];
$scope.filters = {
x: false,
company: '',
search: ''
};
$scope.both ='B';
});
</script>
</body>
</html>
在这里找到我的演示项目https://jsfiddle.net/basilbkodakk/sk549x4m/2/。有3个公司x,y,z .list框显示x和y。 z常见于x,y。在angularjs中的过滤方法