Ember:如何在阵列控制器中定义项目控制器?(Ember: How Can I define an Item Controller in my Array Controller?)

我通过迭代这样的行列表在我的应用程序中创建了一个表:

{{#each visible_page itemController='ScheduledReport'}} ..... {{/each}}

现在,我正在尝试抽象这个表,以便我可以使用它而不仅仅是这些报告。 所以,我想在itemController中定义itemController而不是在模板中内联它:

App.ReportsScheduledController = App.TableController.extend( { itemController : 'scheduledReport'

但是,在itemController中定义ReportsScheduledController - 它继承自Ember.ArrayController - 不会呈现表中的每一行。

知道我在这个设置中做错了什么吗?

谢谢!

I've created a table in my app by iterating through a list of rows like this:

{{#each visible_page itemController='ScheduledReport'}} ..... {{/each}}

Now, I'm trying to abstract this table so that I can use it for more than just these reports. So, I want to define the itemController in the ArrayController rather than inlining it in the template:

App.ReportsScheduledController = App.TableController.extend( { itemController : 'scheduledReport'

However, defining the itemController in the ReportsScheduledController -- which inherits from Ember.ArrayController -- doesn't render each row in the table.

Any idea what I'm doing wrong in this setup?

Thanks!

最满意答案

您需要迭代模板中的控制器才能工作。 迭代控制器中的属性不会应用项目控制器的包装。

You need to iterate over the controller in the template for that to work. Iterating over properties in the controller doesn't apply the wrapping of the item controller.

Ember:如何在阵列控制器中定义项目控制器?(Ember: How Can I define an Item Controller in my Array Controller?)

我通过迭代这样的行列表在我的应用程序中创建了一个表:

{{#each visible_page itemController='ScheduledReport'}} ..... {{/each}}

现在,我正在尝试抽象这个表,以便我可以使用它而不仅仅是这些报告。 所以,我想在itemController中定义itemController而不是在模板中内联它:

App.ReportsScheduledController = App.TableController.extend( { itemController : 'scheduledReport'

但是,在itemController中定义ReportsScheduledController - 它继承自Ember.ArrayController - 不会呈现表中的每一行。

知道我在这个设置中做错了什么吗?

谢谢!

I've created a table in my app by iterating through a list of rows like this:

{{#each visible_page itemController='ScheduledReport'}} ..... {{/each}}

Now, I'm trying to abstract this table so that I can use it for more than just these reports. So, I want to define the itemController in the ArrayController rather than inlining it in the template:

App.ReportsScheduledController = App.TableController.extend( { itemController : 'scheduledReport'

However, defining the itemController in the ReportsScheduledController -- which inherits from Ember.ArrayController -- doesn't render each row in the table.

Any idea what I'm doing wrong in this setup?

Thanks!

最满意答案

您需要迭代模板中的控制器才能工作。 迭代控制器中的属性不会应用项目控制器的包装。

You need to iterate over the controller in the template for that to work. Iterating over properties in the controller doesn't apply the wrapping of the item controller.