使用角度ng-repeat
,如何根据对象数组中的键过滤掉项目?
例如,我有这个数据集:
$scope.data = [
{
name: "Example",
id: 1,
status: "deleted"
},
{
name: "Example",
id: 1,
status: "pending"
},
{
name: "Example",
id: 1,
status: "active"
}
// etc
]
如何使用status: "deleted"
删除项目?
<div ng-repeat="item in data">
<h1>{{item.name}}</div>
<p>Status: {{item.status}}</p>
</div>
答案 0 :(得分:3)
以下是如何在ng-repeat中使用过滤器: -
4.32999992370605
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
$scope.data = [
{
name: "Example",
id: 1,
status: "deleted"
},
{
name: "Example",
id: 1,
status: "pending"
},
{
name: "Example",
id: 1,
status: "active"
}
// etc
]
});
答案 1 :(得分:1)
使用SELECT * FROM test WHERE ('engineer' LIKE CONCAT(columnName,'%')) OR ('engineer' LIKE CONCAT(LOWER(columnName),'%'));
检查状态
ng-if
答案 2 :(得分:-1)
您可以在div中添加ng-if,如
<div ng-repeat="item in data" ng-if="item.status!='deleted'">
<h1>{{item.name}}</div>
<p>Status: {{item.status}}</p>
</div>