search

Home  >  Q&A  >  body text

How to separate data using angular filter

$scope.data=[
                  {"time":"2017/06/23","money":"3000","type":"RMB"},
                  {"time":"2017/06/24","money":"4000","type":"RMB"},
                  {"time":"2017/07/23","money":"3000","type":"RMB"},
                  {"time":"2017/07/23","money":"3000","type":"RMB"},
                  {"time":"2017/07/23","money":"3000","type":"RMB"}
           ];

The requested data is similar to this. The data needs to be displayed based on the time field and the month. How to filter the data in June and July?
For example, when rendering to the page, it should be displayed like this:
June
23 Amount: 3000 Category: RMB
No. 24 Amount: 4000 Category: RMB
July
Amount of 23rd: 3000 Category: RMB
No. 24 Amount: 4000 Category: RMB
25 Amount: 5000 Category: RMB

女神的闺蜜爱上我女神的闺蜜爱上我2708 days ago728

reply all(1)I'll reply

  • 怪我咯

    怪我咯2017-06-28 09:29:13

    var arr = {};
    for(var i=0;i<$scope.data.length;i++){
      var key = $scope.data[i].time.split('/')[1];
        arr[key].push($scope.data[i])
    }
    return arr;

    Purely handwritten, no testing, just writing an idea to further format the object

    reply
    0
  • Cancelreply