angularjs - Count Of JSON data as Daily, Weekly, Monthly in Angular JS -
i have json data consist of array of data , wanted find count tags based on day, week month data
in json data getting date format
2017-08-10t13:14:53.000+0000
maybe you. should day , week , month of base date see. loop through data , issue date ("created": "2017-08-10t13:14:53.000+0000"
) , create new date. check base day,week, month of base date , go on.
var app = angular.module('myapp', []); app.controller("controller", ["$scope", "$http", "$filter", "$window", function($scope, $http, $filter, $window) { $scope.data = { "expand": "schema,names", "startat": 0, "maxresults": 50, "total": 257, "issues": [{ "expand": "operations,versionedrepresentations,editmeta,changelog,renderedfields", "id": "1578077", "fields": { "created": "2017-08-10t13:14:53.000+0000", "resolutiondate": null, "status": { "name": "in progress", "id": "10548" } } }, { "expand": "operations,versionedrepresentations,editmeta,changelog,renderedfields", "id": "1562078", "fields": { "created": "2017-07-27t03:42:24.000+0000", "resolutiondate": null, "status": { "name": "to do", "id": "10548" } } }, { "expand": "operations,versionedrepresentations,editmeta,changelog,renderedfields", "id": "1562078", "fields": { "created": "2017-08-20t03:42:24.000+0000", "resolutiondate": null, "status": { "name": "to do", "id": "10549" } } }, { "expand": "operations,versionedrepresentations,editmeta,changelog,renderedfields", "fields": { "created": "2017-08-11t13:03:52.000+0000", "resolutiondate": null, "status": { "name": "in progress", "id": "3" } }, "id": "1579217" } ] } var d = new date("2017-08-10t13:14:53.000+0000"); var day = d.getday(); var month = d.getmonth(); $scope.daycount = 0; $scope.montheventcount = 0 $scope.today = new date(); //var week = $scope.findthevalue = function() { angular.foreach($scope.data.issues, function(issue) { var issuedate = new date(issue.fields.created); if (issuedate.sethours(0,0,0,0) == $scope.today.sethours(0,0,0,0)) $scope.daycount = $scope.daycount + 1; if (issuedate.getmonth() == month) $scope.montheventcount = $scope.montheventcount + 1; }) } } ]);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <div ng-app="myapp"> <div ng-controller="controller"> <button type="button" ng-click="findthevalue();">submit</button> <div>{{daycount}}</div> <div>{{montheventcount}}</div> {{date}} </div> </div>
Comments
Post a Comment