【问题标题】:Angularjs : Access nested json array values using ng-repeat with groupByAngularjs:使用 ng-repeat 和 groupBy 访问嵌套的 json 数组值
【发布时间】:2017-01-30 05:00:18
【问题描述】:

我已经嵌套了 json 数组,我需要在其中对一些值进行分组。我无法获取用于分组的嵌套标签。

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

如果我将“id”分组,它的工作,如果我将“cash.amount”分组,它不工作

谁能帮我解决这个问题?

【问题讨论】:

    标签: angularjs json grouping ng-repeat


    【解决方案1】:

    你可以的,

    <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>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-06-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多