Ember store query template no model data

别说谁变了你拦得住时间么 提交于 2020-01-06 20:25:15

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!