我有一些包含某些属性的帖子,例如:
[
{
"ID": "2",
"ID_user": "6",
"NameUser": "Ary",
"image": "/images/users/ary.jpg",
"creationDate": "2016-05-16 00:00:00",
"lastEditDate": "2016-05-24 14:19:18",
"section": [
{
"section": "Front Page",
"ID_sect": "10"
}
]
},
{
"ID": "17",
"ID_user": "1",
"NameUser": "dev",
"image": "/images/users/dev.jpg",
"creationDate": "2016-05-18 10:44:38",
"lastEditDate": "2016-05-24 14:58:16",
"section": [
{
"section": "Front C",
"ID_sect": "13"
}
]}
我有部分的复选框。当我检查我需要的任何部分时,它只显示带有所选部分的帖子。复选框是:
<ul class="filterlist" >
<li ng-repeat="section in sections">
<input type="checkbox" ng-model="sectionCB" value="{{section.ID}}">{{section.name}}</input>
</li>
</ul>
当我展示帖子时:
<tr class="dashboardTr" ng-repeat="post in posts | filter:sectionCB | filter:search>
<td id="checkboxColumn"><input type="checkbox" name="actions" class="actions" id="{{post.ID}}"
value="{{post.ID}}" ng-model="post.Selected">
</td>
<td id="titleColumn"><a href="">{{ post.title }}</a>
</td>
<td id="sectionColumn">
<select class="form-control sectionsClass" id="sectionsSelect-{{post.ID}}" ng-change="updateSection(sectionsModel,this)"
ng-model="sectionsModel" >
<option ng-repeat="section in sections" id="option-{{section.ID}}">{{section.name}}</option>
</select>
</td>
</tr>
搜索过滤器适用于另一个有效的过滤器。当我在输入类型=文本中写入内容时,它会按照书面文本进行操作和过滤。
我做了那个过滤器:
app.filter('bySection', function(){
return function(posts, start){
var out = [];
var sections = $('input[name="sections"]:checked');
if(sections.length == 0)
return posts;
for(var i = 0; i<sections.length; i++){
if(sections[i] == posts.section)
out.push(posts);
}
return out;
}
});
我需要按部分进行过滤,但它不起作用 谢谢!