本文介绍了ember.js错误:断言失败:来自findAll的响应必须是Array,而不是未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
也许这是最愚蠢的问题,但仍然是如何手动查询服务器的某些模型的记录? 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}, :6,caption:review}]}
解决方案
完全合法的问题
您应该使用 camelCase
查询:
this.store.find('urlType')
,你的json键应该是 camelCase
(你也可以使用一个序列化程序来修复它):
{
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
}
]
}
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"}]}
解决方案
totally legitimate question,
you should query it using camelCase
:
this.store.find('urlType')
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的响应必须是Array,而不是未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!