正如标题所说,我希望找到一种方法来改变 Ember.ComputedProperty 的上下文或范围。
我的用例是我允许用户定义用于动态绑定的 bindingConfig 属性。此 bindingConfig 可以是字符串或函数或 Ember.ComputedProperty。
因为 bindingConfig 是与 Content/Model 分开传递的,因此我需要将它绑定到内容,而且我还没有找到对 Ember.ComputedProperty 执行此操作的方法。
非常感谢, :)
正如标题所说,我希望找到一种方法来改变 Ember.ComputedProperty 的上下文或范围。
我的用例是我允许用户定义用于动态绑定的 bindingConfig 属性。此 bindingConfig 可以是字符串或函数或 Ember.ComputedProperty。
因为 bindingConfig 是与 Content/Model 分开传递的,因此我需要将它绑定到内容,而且我还没有找到对 Ember.ComputedProperty 执行此操作的方法。
非常感谢, :)
Here's what your example shows:
{{my-component content=appObj bindingConfig="name"}}
{{my-component content=appObj bindingConfig=nickName}}
Which is identical to this:
{{my-component content=appObj bindingConfig="name"}}
{{my-component content=appObj bindingConfig="Darth Meow"}}
Considering there is no Darth Meow
property on the appObj
(or content
), ember is behaving as expected.
What you want is this:
{{my-component content=appObj bindingConfig="name"}}
{{my-component content=this bindingConfig="nickName"}}
The second component will now look up the nickName
property on your controller
.