Ember存储查询模板没有模型数据 [英] Ember store query template no model data
本文介绍了Ember存储查询模板没有模型数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何Ember模型存储查询
不会更新模板模型数据, find
是否有效?
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);
}
推荐答案
所以我想出了为什么我模板没有呈现模型数据。使用 store.query
,它期望多个结果,而 store.find
只需要一个结果,这就是为什么它的工作。我正在使用 server_address
作为查找中的id,但它开始让我受益。
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.
这是我得到的 store.query
可以处理单个结果。
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");
});
这篇关于Ember存储查询模板没有模型数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文