如图一,一个表格中有很多很多数据,其中,状态为以下四种:1)'issued': '已发布',2)'deleted': '已删除',3)'reported': '已举报',4)'masked': '已屏蔽'
试过<tr ng-repeat="post in filterPostList | filter:'status':'issued'||'masked'">这样只能显示出issued的数据。现在想要显示issued和masked的数据,该怎么办?
<tr ng-repeat="post in filterPostList | filter:'status':'issued'||'masked'">
欢迎选择我的课程,让我们一起见证您的进步~~
Write a custom filter
app.filter("statusFilter",function(){ return function(input,uppercase){ var out = []; for(var i=0 ; i<input.length; i++){ if(input[i].status=='issued'||input[i].status=='masked'){ out.push(input[i]); } } return out; } });
HTML:
<tr ng-repeat="post in filterPostList | statusFilter>
No need to write filters
Just write a function
$scope.statusFilter = function(item){ return item.status == 'issued' || item.status == 'masked'; } <tr ng-repeat="post in filterPostList | filter: statusFilter">
Suddenly realized that I answered a question with a long history. . . .
Another way of thinking. No need to write filters or functions.
Write a custom filter
HTML:
No need to write filters
Just write a function
Suddenly realized that I answered a question with a long history. . . .
Another way of thinking. No need to write filters or functions.