我有以下路由器:
Whistlr.OrganizationsNewRoute = Ember.Route.extend
model: ->
Whistlr.Organization.createRecord()
setupController: (controller, model) ->
@controllerFor('organization').set('content', model)这在新的组织形式中被调用,它有几个绑定的输入,如:
Em.TextField valueBinding="name"当我在这些输入中输入数据时,我会得到以下错误消息:
Cannot delegate set('name', C) to the 'content' property of object proxy <Whistlr.OrganizationsNewController:ember519>: its 'content' is undefined.这告诉我控制器没有被路由器正确地设置。为什么会发生这种事?
发布于 2013-07-31 06:52:01
原因是您正在将模型设置为Whistlr.OrganizationsController,其中Whistlr.OrganizationsNewRoute的controller将是Whistlr.OrganizationsNewController,其内容没有设置,因为您已经重写了setupController of Whistlr.OrganizationsNewRoute。
如果希望Whistlr.OrganizationsNewRoute将Whistlr.OrganizationsController作为默认控制器,则可以通过
Whistlr.OrganizationsNewRoute = Ember.Route.extend({
controllerName: 'organization'
});它将Whistlr.OrganizationsController设置为您的Whistlr.OrganizationsController的默认控制器,这样您可能也不需要覆盖setupController。但这个只有师父才能买到。
如果使用RC构建<= 1.0.0.RC6,则必须在renderTemplate of Whistlr.OrganizationsNewRoute中提及控制器。
Whistlr.OrganizationsNewRoute = Ember.Route.extend({
setupController: function(controller,model) {
this.controllerFor('organization').set('content', model)
},
renderTemplate: function(){
this.render({ controller: 'organization' });
}
});发布于 2013-07-31 04:13:35
如果您不返回任何内容,则从模型钩子返回的值将分配给模型property.In setupController模型。
模型:->返回Whistlr.Organization.createRecord()
https://stackoverflow.com/questions/17961060
复制相似问题