$scope.users = [{
"firstname": "Steve",
"lastname": "Jobs",
"id": 1,
"userLog": {
"id": 1,
"userId": "Steve01",
"enabled": true
}
}, {
"firstname": "Michelle",
"lastname": "Jobs",
"id": 2,
"userLog": {
"id": 2,
"userId": "Michelle02",
"enabled": false
}
}];
<div ng-repeat="user in users| filter: { enabled: true } track by user.userLog.id ">
帮助我如何过滤如果启用是真的,用户详细信息将显示其他隐藏。
由于
答案 0 :(得分:2)
<div ng-repeat="user in users| filter: { userLog.enabled: true } track by user.userLog.id ">
答案 1 :(得分:0)
<强>的js 强>
<div ng-repeat="user in users | filter: {userLog :{enabled:true}}">
{{user.firstname}}
</div>
示例强>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.users = [{
"firstname": "Steve",
"lastname": "Jobs",
"id": 1,
"userLog": {
"id": 1,
"userId": "Steve01",
"enabled": true
}
}, {
"firstname": "Michelle",
"lastname": "Jobs",
"id": 2,
"userLog": {
"id": 2,
"userId": "Michelle02",
"enabled": false
}
}];
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myApp" ng-controller="myCtrl">
<div ng-repeat="user in users | filter: {userLog :{enabled:true}}">
{{user.firstname}}
</div>
</div>
答案 2 :(得分:0)
试试这个:
<div ng-repeat="user in users | filter: (!user.userLog.enabled || '') track by user.userLog.id">