Ember.js Ember js如何设置控制器';带DS.FixtureAdapter的s型号?
如何正确设置控制器的型号 以下是我的代码(获取错误):Ember.js Ember js如何设置控制器';带DS.FixtureAdapter的s型号?,ember.js,ember-data,Ember.js,Ember Data,如何正确设置控制器的型号 以下是我的代码(获取错误): window.App=Ember.Application.create(); App.Store=DS.Store.extend({ 修订:11, 适配器:“DS.FixtureAdapter” }); App.ApplicationRoute=Ember.Route.extend({ setupController:function(){ this.controllerFor('topic').set('model',App.topic
window.App=Ember.Application.create();
App.Store=DS.Store.extend({
修订:11,
适配器:“DS.FixtureAdapter”
});
App.ApplicationRoute=Ember.Route.extend({
setupController:function(){
this.controllerFor('topic').set('model',App.topic.find());
}
});
App.Topic=DS.Model.extend({
标签:DS.attr('string'),
所选:DS.attr('boolean')
});
App.Topic.FIXTURES=[
{id:1,标签:“1.第一个主题”,所选:true},
{id:2,标签:'2.第二个主题'},
{id:3,标签:'3.第三个主题'},
];
App.TopicController=Ember.ArrayController.extend();
App.IndexController=Ember.ObjectController.extend({
内容:[],
测试:'索引测试',
当前主题:空
});
模板(尝试将TopicController绑定到Ember。选择视图)
{{查看余烬。选择
contentBinding=“App.TopicController”
selectionBinding=“currentTopics”
optionLabelPath=“content.label”
optionValuePath=“content.id”}
版本:
余烬1.0.0-pre4
余烬数据修订版11
关于这一点正在进行讨论,但到目前为止,余烬控制器对
模型使用别名内容
,因此您的设置控制器应为:
App.ApplicationRoute = Ember.Route.extend({
setupController: function() {
this.controllerFor('topic').set('content', App.Topic.find());
}
});
此外,您还可以签出使用FixtureAdapter
的。请记住这是一项正在进行的工作,我会在有时间的时候更新它
关于这一点正在进行讨论,但到目前为止,余烬控制器对模型使用别名内容
,因此您的设置控制器应为:
App.ApplicationRoute = Ember.Route.extend({
setupController: function() {
this.controllerFor('topic').set('content', App.Topic.find());
}
});
此外,您还可以签出使用FixtureAdapter
的。请记住这是一项正在进行的工作,我会在有时间的时候更新它
谢谢。我已经改为“content”,看起来还可以,但我仍然不知道如何将contentBinding添加到view Ember.Select。我已尝试此{view Ember。选择contentBinding=“App.TopicController.content”
,但获取未捕获错误:断言失败:无法在未定义的对象上使用“length”调用get。请尝试简单地设置content
(或view.content
)。我想你设置绑定的方式在某个时候被弃用了。我花了一整天的时间试图让ember数据正常工作,这个版本终于让我的应用程序正常工作了,谢谢!谢谢。我已经改为“content”,看起来还可以,但我仍然不知道如何将contentBinding添加到view ember.Select。我已经尝试过了此{view Ember.Select
contentBinding=“App.TopicController.content”
但获取未捕获错误:断言失败:无法在未定义的对象上使用“length”调用get。请尝试简单地设置content
(或view.content
)。我想你设置绑定的方式在某个时候已经被弃用了。我花了一整天的时间试图让余烬数据正常工作,这个版本终于让我的应用程序正常工作了,谢谢!
App.ApplicationRoute = Ember.Route.extend({
setupController: function() {
this.controllerFor('topic').set('content', App.Topic.find());
}
});