I have a trouble with asynchronously loaded models in Ember. I thought I have already understood the whole "background Ember magic", but I haven't.
I have two models, let's say foo and boo with these properties:
foo: category: DS.belongsTo("boo", { async: true })
boo color: DS.attr("string")
In my route, I load all foo
s:
model: function(params) {
return this.store.findAll("task", "");
},
than in my template I render a component: {{my-component model=model}}
. In the component's code I need to transform the model into another form, so I have:
final_data: function() {
this.get("model").forEach(function(node) {
console.log(node.get("category"));
});
return {};
}.property("model"),
When I try to access the "category" in the model, my code crashes:
EmberError@http://localhost:4200/assets/vendor.js:25705:15
ember$data$lib$adapters$errors$$AdapterError@http://localhost:4200/assets/vendor.js:69218:7
ember$data$lib$adapters$rest$adapter$$RestAdapter<.handleResponse@http://localhost:4200/assets/vendor.js:70383:16
ember$data$lib$adapters$rest$adapter$$RestAdapter<.ajax/</hash.error@http://localhost:4200/assets/vendor.js:70473:25
jQuery.Callbacks/fire@http://localhost:4200/assets/vendor.js:3350:10
jQuery.Callbacks/self.fireWith@http://localhost:4200/assets/vendor.js:3462:7
done@http://localhost:4200/assets/vendor.js:9518:1
.send/callback@http://localhost:4200/assets/vendor.js:9920:8
It seems to me, like the Ember didn't load the boo
s. How should I access them right to make Ember load them?
Aucun commentaire:
Enregistrer un commentaire