In my Firebase array-snapshot, I have entries for my application that include a "referenceDate" timestamp:
entry [0] { referenceDate: 2017-08-03,...
entry [1] { referenceDate: 2017-08-02,...
entry [2] { referenceDate: 2017-08-01,...
entry [3] { referenceDate: 2017-07-03,...
entry [4] { referenceDate: 2017-07-02,...
I am looking to group these entries by month and year with the following format:
08.2017
03.08.2017
02.08.2017
01.08.2018
07.2017
03.07.2017
02.07.2017
My approach is to create a nested array structure like this:
{"monthYear": "08.2017":[
{"referenzDatum": 2017-08-03},... },
{"referenzDatum": 2017-08-02},... },
{"referenzDatum": 2017-08-01},... },]},
{"monthYear": "07.2017":[
{"referenzDatum": 2017-07-03},... },
{"referenzDatum": 2017-07.02},... }, ...]}
I then plan to loop over this structure using two ngFor loops to generate the HTML output.
Does anyone have a more efficient way to achieve this? The code snippet I tried doesn't scale well beyond a few different months and looks messy.