Ember data has many records loaded only in the canonicalState property

My application index route receives data from the server using the Ember.$.getJSON(url)route model method. Then the response is put into storage using the pushPayload method. When I do foo.get('bars')where it foohas a lot bars(still in the hook of the model), this leads to empty bars . If you look at the server response and the ember inspector,, there really are some data on the foo bars . So I researched foo.get('bars')using the chrome console and found that bars entries are loaded into my canonicalState resource . So my workaround is to use foo.get('bars.canonicalState').

While it works well, but since it feels hacked and I cannot find the canonicalState property in the ember documentation, I would like to know if this is the right way to do this? and why is this happening?

+4
source share
1 answer

In your own, controllertry the following ...

...
myBars: Ember.computed.map('foo.bars', function(bar) { return bar; }),
...

Then you should have access to myBarshow a properly constructed array of objects bar.

0
source

Source: https://habr.com/ru/post/1584589/


All Articles