ember.js 错误:断言失败:来自 findAll 的响应必须是一个数组,而不是未定义的 [英] ember.js Error: Assertion Failed: The response from a findAll must be an Array, not undefined
本文介绍了ember.js 错误:断言失败:来自 findAll 的响应必须是一个数组,而不是未定义的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
也许这是有史以来最愚蠢的问题,但仍然 - 如何手动查询服务器以获取特定模型的记录?
Maybe this is the dumbest question ever but still - how to manually query server for the records of the certain model?
App.UrlNewRoute = Ember.Route.extend({
setupController: function(controller, model) {
console.dir(1);
this.store.find('UrlType').then(function(url_types) {
controller.set('urlTypes',url_types);
});
}
});
{"url_types":[{"id":1,"caption":"text link"},{"id":2,"caption":"guest post"},{"id":3,"caption":"blog comment"},{"id":4,"caption":"banner"},{"id":5,"caption":"profile"},{"id":6,"caption":"review"}]}
推荐答案
完全合法的问题,
你应该使用camelCase
来查询:
this.store.find('urlType')
并且你的 json 键也应该是 camelCase
(你也可以使用序列化器来修复它):
and your json key should be camelCase
also (you can also use a serializer to fix it up):
{
"urlTypes":[
{
"id":1,
"caption":"text link"
},
{
"id":2,
"caption":"guest post"
},
{
"id":3,
"caption":"blog comment"
},
{
"id":4,
"caption":"banner"
},
{
"id":5,
"caption":"profile"
},
{
"id":6,
"caption":"review"
}
]
}
http://emberjs.jsbin.com/OxIDiVU/301/edit
这篇关于ember.js 错误:断言失败:来自 findAll 的响应必须是一个数组,而不是未定义的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文