我已经嵌套了json数组,其中我需要使用一些值进行分组。我无法获取嵌套标记进行分组。
$scope.sampleTest = [{"id": "1", "cash": {"amount":"4000"}},
{"id": "2", "cash": {"amount":"2000"}}]
如果我正在将'id'分组工作,如果我将'cash.amount'分组,那就无法正常工作
有人可以帮我解决这个问题吗?
答案 0 :(得分:0)
你可以,
<div ng-repeat="record in sampleTest | filter: {cash:{amount:'2000'}}:true ">
<强>样本强>
var app = angular.module('todoApp', []);
app.controller("dobController", ["$scope",
function($scope) {
$scope.sampleTest = [{"id": "1", "cash": {"amount":"4000"}},
{"id": "2", "cash": {"amount":"2000"}},
{"id": "3", "cash": {"amount":"2000"}}];
}
]);
<!DOCTYPE html>
<html ng-app="todoApp">
<head>
<title>Sample</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular.min.js"></script>
</head>
<body ng-controller="dobController">
<div ng-repeat="record in sampleTest | filter: {cash:{amount:'2000'}}:true ">
<ul>
<li >{{ record}}</li>
</ul>
</div>
</body>
</html>