2017-01-30 73 views
0

我嵌套了json数组,其中我需要组合一些值。我无法获取嵌套标签进行分组。Angularjs:使用ng-repeat与groupBy访问嵌套的json数组值

$scope.sampleTest = [{"id": "1", "cash": {"amount":"4000"}}, 
        {"id": "2", "cash": {"amount":"2000"}}] 

如果我是分组“身份证”的工作。如果我的分组“cash.amount”它不工作

谁能帮我解决这个问题呢?

回答

0

你可以做,

<div ng-repeat="record in sampleTest | filter: {cash:{amount:'2000'}}:true "> 

DEMO

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>