我是AngularJS中的新成员。我能够通过文本框搜索列表,但无法使用复选框。AngularJs |按文本框和多个相同名称的复选框进行过滤
这是我的HTML代码。
<input id="search_keywords" ng-model="keyword" type="text" value="" placeholder="Keywords" name="search_keywords">
<input id="search_location" ng-model="location" type="text" value="" placeholder="Location" name="search_location">
,并使用复选框以相同的形式
<input type="checkbox" ng-model="categories[category]" />Full Time</label>
<input type="checkbox" ng-model="categories[category]" />Part Time</label>
<input type="checkbox" ng-model="categories[category]" />Contract</label>
<input type="checkbox" ng-model="categories[category]" />Freelance</label>
<ul class="job-fillter-listings-wr">
<li class="job-list" ng-repeat="x in searchData | filter : {'keyword' : keyword, 'location' : location, 'categories' : categories } ">
<a href="">
<div class="center-wr">
<div class="all-job-list clearfix">
<div class="job-title-section">
<span class="job-title-"><i class="fa fa-star" aria-hidden="true"></i> | {{ x.keyword }}</span>
</div>
<div class="job-location">{{ x.location }}</div>
</div>
</div>
</a>
</li>
</ul> <!--job-fillter-listings-wr-->
角JS代码
<script type="text/javascript">
var app = angular.module('myApp', []);
app.controller('arrCtrl', function($scope) {
$scope.searchData = [
{
"keyword": "Sr. Front-End Developer",
"categories": "Part Time",
"location": "Toronto"
},
{
"keyword": "Sr. Developer/Architect",
"categories": "Full Time",
"location": "Toronto"
},
{
"keyword": "Sr. .NET Developer",
"categories": "Contract",
"location": "Pickering"
},
{
"keyword": "Business Analyst (Contract)",
"categories": "Contract,Freelance",
"location": "Pickering"
}
]
});
</script>
我怎么能过滤由复选框也榜上有名?
感谢
非常感谢。它的工作:-) –