如何从 ember 组件内部获取外部父控制器?
How to get the outer parent controller from inside an ember component?
目前我正在像这样将自定义关键字传递到组件中(当我遍历数组控制器中的每个模型时)
{{#each thing in controller}}
{{my-thing foo=controller}}
{{/each}}
然后在我的组件中我可以添加一个自定义属性绑定并绑定到 "foo" 但我想我可以访问父控制器(从组件本身内部)
我还能如何从 ember 1.8+ 中的组件内部获取此信息?
查看 targetObject
:
If the component is currently inserted into the DOM of a parent view, this property will point to the controller of the parent view.
在Component中,可以使用this.get('targetObject');
获取父视图的Controller
目前我正在像这样将自定义关键字传递到组件中(当我遍历数组控制器中的每个模型时)
{{#each thing in controller}}
{{my-thing foo=controller}}
{{/each}}
然后在我的组件中我可以添加一个自定义属性绑定并绑定到 "foo" 但我想我可以访问父控制器(从组件本身内部)
我还能如何从 ember 1.8+ 中的组件内部获取此信息?
查看 targetObject
:
If the component is currently inserted into the DOM of a parent view, this property will point to the controller of the parent view.
在Component中,可以使用this.get('targetObject');
获取父视图的Controller