我怎样才能捕捉到$scope.personConOferta
拥有的人oferta
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
<div ng-repeat="person in personas">
{{ person }}
</div>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $filter) {
$scope.personas = [
{
"Codigo": 1,
"Name": "alberto",
"Offerta": [
{
"precio": 10000,
"lugar": "Medellin"
},
{
"precio": 2000000,
"lugar": "Bogota"
}
]
},
{
"Codigo": 2,
"Name": "albertoPalacios",
"Offerta": []
}
]
$scope.personConOferta = $filter('filter')($scope.personas, { Offerta.length > 0 }, true);
$scope.personSinOferta = $filter('filter')($scope.personas, { Offerta.length == 0 }, true);
});
</script>
</body>
</html>
打开严格模式,这样它只会过滤你的精确匹配。这是通过在搜索条件后添加 true 来完成的。