DEBUG: -------------------------------
DEBUG: Ember : 2.3.0
DEBUG: Ember Data : 2.3.1
DEBUG: jQuery : 2.1.4
DEBUG: Ember Simple Auth : 1.0.0
DEBUG: -------------------------------
My server side send the data with jsonapi
like this:
data: [{
... ,
1: {
attributes: {
id: '123',
... ,
meta: {
price_total: {
datasets: ... ,
labels: ...
}
}
}
},
...
}]
I check the document https://guides.emberjs.com/v2.3.0/models/handling-metadata/ , check to get the metadata in my template.
{{#each model as |fittingItem index|}}
...
{{fittingItem.meta}}
...
{{/each}}
I could not get meta.
I found some issues https://github.com/emberjs/data/issues/2905 , https://github.com/emberjs/data/issues/3419 . They also can not solve my problem.
Maybe there is any better way to approach this problem?
Metadata (as it relates to JSONAPI) is currently only supported in Ember-Data for collections of data, and should be defined as a top level document key.
http://jsonapi.org/format/#document-top-level
It appears what you are trying to achieve is some level of meta data for each individual record, which is possible if you define a custom meta attribute on your model definition.
fooMeta: DS.attr()
Using an empty attr()
allows ember-data to just let any value from json to "pass through" to your model without any transformation.. (though you could also define a custom transform to tweak your meta values a bit...)
also there is an addon ember-data-model-fragments which, may be of some help defining arbitrary "chunks" of data within your models.