-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Description
groupBy does not work if you are trying to group using Ember's date attribute. Suppose we have a model:
// app/models/entry.js
export default Model.extend({
name: attr('string'),
date: attr('date'),
});
And we get data from a JSON endpoint that looks like this:
[
{
"name": "Object 1",
"date": "2015-09-29",
},
{
"name": "Object 2",
"date": "2015-09-30",
},
{
"name": "Object 3",
"date": "2015-09-30",
},
]
We have a controller that uses groupBy to group them by the date attribute:
// app/controllers/view.js
import Ember from 'ember';
import groupBy from 'ember-group-by';
export default Ember.Controller.extend({
entriesByDate: groupBy('model', 'date')
});
Which we then use in a template:
{{#each entriesByDate as |group| }}
<h1>{{group.value}}</h1>
{{#each group.items as |entry| }}
{{entry.name}}<br>
{{/each}
{{/each}
We would expect the output to be:
<h1>2015-09-29</h1>
Object 1<br>
<h1>2015-09-30</h1>
Object 2<br>
Object 3<br>
However, groupBy puts each of the entries into their own group. Changing the attr in the model from date to string gives the expected output.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels