当您尝试向 ObjectController
添加绑定(bind)时,它不起作用。
App.FailController = Em.ObjectController.extend({
content: null,
myBinding: "App.router.myController" // <-- fails
});
错误:
Uncaught Error: assertion failed: Cannot delegate set('my', ) to the 'content' property of object proxy <.FailController:ember154>: its 'content' is undefined.
它尝试将其添加到 content
属性中。
jsFiddle:demo
最佳答案
鸣谢:至 caligo-mentis谁answered这个在 github 上。
ObjectProxy
将对 set
的任何调用委托(delegate)给 content
属性,除非 ObjectProxy
上存在同名属性代码 > 实例。简单的解决方案是在声明绑定(bind)之前定义具有所需名称的属性。
App.FailController = Em.ObjectController.extend({
my: null,
myBinding: "App.router.myController" // <-- works
});
jsFiddle:demo
关于ObjectController 上的绑定(bind) - Ember.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12502465/