AngularJS GroupBy Week,Month,Year和Sum

时间:2018-03-07 11:31:29

标签: angularjs



angular.module('myApp', ["angular.filter"])

.controller('TodoCtrl', function($scope, $http){
$scope.ctrl = {};

$http({
      url: 'https://ima.baguscloud.com/voezie/rest-api.php?json=expense',
      method: 'GET',
      dataType: 'json', 
      data: '',         
      headers: {
        'Content-Type': 'application/json'
      }
    }).success(function (data, status, headers, config) {
      $scope.ctrl_expenses = data;
    });
        
});

<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.8/angular.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-filter/0.5.17/angular-filter.js"></script>
<div ng-app="myApp" >
<div ng-controller="TodoCtrl" ng-init="var_expenses={}">
  <div ng-repeat="item in ctrl_expenses" ng-init="var_expenses[$index]=item_expense">{{ item.date|date:'Week ww of yyyy'}} Rp.{{ item.nominal_expense|number:0}},-
  </div>
</div>
</div >
&#13;
&#13;
&#13;

我需要汇总数据列表包含&#34; date&#34;和&#34; nominal_expense&#34;,但不知道如何按周,月,年分组。我试过使用GroupBy&#34; angular.filter&#34;分组日期,但它不适用于工作日,月份和年份

请帮助我如何使它工作

我创建显示日期列表的代码片段,请帮我制作周组列表和月份列表

0 个答案:

没有答案