问题
How come Ember model store query
doesn't update template model data and find
does?
// This doesn't update the template, when loading website no information is displayed but the data is loaded
model: function() {
var parentModel = this.modelFor("server.view");
return this.store.query("server", { server_address: parentModel.server_address });
}
// This works without any problems
model: function() {
var parentModel = this.modelFor("server.view");
return this.store.find("server", 1);
}
回答1:
So I figured out why my template was not rendering model data. Using store.query
it expects multiple results while store.find
expects only one result and that's why it worked. I was using server_address
as an id in find but it started to get in my way.
Here's how I got store.query
to work on a single result.
return this.store.query("server", { param: value }).then(function(res) {
return res.get("firstObject");
});
来源:https://stackoverflow.com/questions/31821443/ember-store-query-template-no-model-data