Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ember.js Ember this.get(';controller';)返回父控制器_Ember.js - Fatal编程技术网

Ember.js Ember this.get(';controller';)返回父控制器

Ember.js Ember this.get(';controller';)返回父控制器,ember.js,Ember.js,我有一个graphHolderController,用于呈现此模板: {{#each controller.graphs}} {{view sidePanelView}} {{view graph}} {{/each}} 在侧面板视图中,我想调用侧面板控制器上的一个方法,但我发现在侧面板视图中,this.get('controller')返回graphHolderController的一个实例。如何从SidePanelView调用SidePanelController上的方法?问题是{

我有一个
graphHolderController
,用于呈现此模板:

{{#each controller.graphs}}
  {{view sidePanelView}}
  {{view graph}}
{{/each}}

侧面板视图
中,我想调用
侧面板控制器
上的一个方法,但我发现在
侧面板视图
中,
this.get('controller')
返回
graphHolderController
的一个实例。如何从
SidePanelView
调用
SidePanelController
上的方法?

问题是
{{view}
helper确实呈现了作为第一个参数传递的视图,但绑定了与父视图中相同的控制器


如果需要知道操作来自哪个图形,请将方法移动到
graphHolderController
,并将模型作为该操作的参数发送。

问题在于
{{view}}
帮助程序确实呈现了作为第一个参数传递的视图,但绑定了与父视图中相同的控制器


如果需要知道操作来自哪个图形,请将方法移动到
graphHolderController
,并将模型作为该操作的参数发送。

如果希望视图由其自己的单独控制器管理,建议使用渲染辅助工具:
{render sidePanel}
。这将呈现
侧面板
模板,由
侧面板视图
和单个
侧面板控制器
支持


如果
sidePanelController
需要管理特定模型的状态,请将该模型作为上下文传递:
{{render sidePanel this}}
(其中
this
表示模型)。这将生成一个新的非单例
sidePanelController
,以便仅管理此模型。由于您在
{{each}
块中进行渲染,我猜您希望采用这种方法。

如果希望视图由其自己的单独控制器管理,我建议使用渲染辅助工具:
{render sidePanel}
。这将呈现
侧面板
模板,由
侧面板视图
和单个
侧面板控制器
支持


如果
sidePanelController
需要管理特定模型的状态,请将该模型作为上下文传递:
{{render sidePanel this}}
(其中
this
表示模型)。这将生成一个新的非单例
sidePanelController
,以便仅管理此模型。由于您在
{{each}
块中进行渲染,我想您应该采用这种方法。

也许我应该使用
{{control sidePanelView}}
?是的,这也是可能的,但我不想建议使用未完成的特性,因为
{control}
现在已经存在。也许我应该使用
{{control sidePanelView}
?是的,这也是可能的,但我不想建议使用
{{control}}
目前正在使用的未完成功能。