0
我想知道如何創建一個值爲「無酒精」的複選框過濾器,因此每次檢查時都會通過該數組並選擇僅含「無酒精」類型的啤酒?複選框過濾器
var app = angular.module("myModule", []);
app.controller("MainController", function($scope) {
$scope.beer = [
{ name: "beer1", price: 20, type:"Alcohol"},
{ name: "beer2", price: 55, type:"no Alcohol" },
{ name: "beer3", price: 20, type:"Alcohol" },
{ name: "beer4", price: 37, type:"no Alcohol" },
{ name: "beer5", price: 20, type:"Alcohol" },
{ name: "beer6", price: 32, type:"Alcohol" }
];
});
<!DOCTYPE html>
<html ng-app="myModule">
<head>
\t <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" integrity="sha512-dTfge/zgoMYpP7QbHy4gWMEGsbsdZeCXz7irItjcC3sPUFtf0kuFbDz/ixG7ArTxmDjLXDmezHubeNikyKGVyQ==" crossorigin="anonymous">
\t <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script>
\t <script src="file:///C:/Users/LG/Documents/Angularteste/Teste/app.js"></script> \t
</head>
<body>
<div ng-controller="MainController">
<form class="form-inline">
<input type="text" ng-model="test.name">
<input type="text" ng-model="test.type">
<input type="checkbox" ng-model="exactMatch"/> Exact Match
</form>
<ul ng-repeat="friend in beer | filter:test:exactMatch">
<li>{{friend.name}}</li>
<li>{{friend.type}}</li>
</ul>
</div>
\t \t <input type="checkbox" ng-model='search.type1' ng-true-value="no alcohol" ng-false-value='' /> Would you like beer with no alchol?
</body>
</html>