我正在尝试过滤并仅显示未删除的用户(有效)
其中let appDelegate = UIApplication.shared.delegate as! AppDelegate
appDelegate.window?.rootViewController = newController
是表,users
是列(时间戳)。
deleted_at
我在这里做什么错了?
答案 0 :(得分:1)
尝试这样。我希望它能为您提供帮助。
<tr ng-repeat="user in users | filter: {!user.deleted_at}" ng-class="{'success': userData.id == user.id }" style="background-color:{{'userData.color'}}" ng-if="selectedRole == '' || (user.group_list | lookup:GROUPS | lists:'name' | join).indexOf(selectedRole) != -1">
答案 1 :(得分:1)
只需使用filter : {deleted_at : null}
function myctrl($scope){
$scope.users = [
{"name":"Hardik Shah", "deleted_at" : null},
{"name" : "I am deleted", "deleted_at": "2343434"},
{"name": "I am not deleted", "deleted_at": null}
]
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<table ng-app = "" ng-controller="myctrl">
<tr ng-repeat="user in users | filter : {deleted_at : null}">
<td>
{{user.name}}
</td>
</tr>
</table>
答案 2 :(得分:1)
您可以创建一个函数来过滤数组并将其传递给ng-repeat
function ctrl($scope){
$scope.users = [
{id: 1, deleted_at: null},
{id: 2, deleted_at: "12345"},
{id: 3, deleted_at: null}
]
$scope.userFilter = user => user.deleted_at
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<table ng-app ng-controller="ctrl">
<tr ng-repeat="user in users | filter: userFilter">
<td>
{{user.id}}
</td>
</tr>
</table>