ember.js如何在每个内部渲染出口

时间:2013-04-30 16:30:33

标签: ember.js handlebars.js

我正在尝试执行以下操作:

我在表格中有一个列表

<table>
{{#each controller}}
  <tr> 
    <td>
      {{#linkTo person this}}{{name}}{{/linkTo}}
    </td>
  </tr>
{{/each}}
</table>

我希望在项目本身之后呈现项目的详细信息。这样:

<table>
{{#each controller}}
  <tr> 
    <td>
      {{#linkTo person this}}{{name}}{{/linkTo}}
    </td>
  </tr>
  <tr>
    {{outlet}}
  </tr>
{{/each}}
</table>

不幸的是它不起作用。 Ember希望将插座放在每个插座之外。 我可以做点什么吗?可能是一个背景变化?或者我唯一能做的就是操纵dom? (那不是最好的!!)

谢谢

1 个答案:

答案 0 :(得分:2)

您无法在{{outlet}}循环内使用{{each}}帮助程序。一些替代方案:

//Basic view helper
{{view App.Item}}

<!-- Block view helper -->
{{#view App.Item}}
   <!-- template here -->
{{/view}}

<!-- just the template -->
{{template item}}

<!-- same as template but with leading _underscore -->
{{partial item}}
相关问题