0

I have an array of data with dates and other variables.

var array = {
    'row1' : {
        'date' : '2018-03-31 18:00',
        'value' : 3
    },
    'row2' : {
        'date' : '2018-03-31 19:00',
        'key4' : 7
    }
    'row3' : {
        'date' : '2018-04-01 00:00',
        'value' : 3
    },
    'row3' : {
        'date' : '2018-04-02 02:00'',
        'value' : 19
    }
};

What I want to is to make a new div for each day with every value for the day. So the desired output is as follow

<div class="all">
  <div class="day">
    <span>2018-03-31</span>
    <span>18:00 3</span>
    <span>19:00 7</span>
  </div>
  <div class="day">
    <span>2018-04-01</span>
    <span>00:00 3</span>
  </div>
  <div class="day">
    <span>2018-04-02</span>
    <span>02:00 19</span>
  </div>
</div>

The only solution I can think of is running ng-repeat twice but that is not very efficient. There must be a more efficient way to do this.

user997299
  • 335
  • 2
  • 11
  • 1
    You could preprocess the array by grouping on the date. This post seems to be useful: https://stackoverflow.com/a/24879563/6996150 – johey Nov 09 '18 at 12:29
  • It's unclear what your potential solution would do, and it's also unclear why it would not be efficient. Don't make assumptions. Find a clean, logical, readable solution, implement it, test it, and see if it is efficient. – JB Nizet Nov 09 '18 at 12:30

0 Answers0