0

我有 3 个模型货币、收入和收入操作。我想在某些路线上渲染它们。正确的方法是什么?如何在一页上渲染三个模型?

UPD:这些模型之间没有任何关联。

route.js.coffee

@route 'addincome', { path: 'operations/addincome' }

EmberMoney.AddincomeRoute = Ember.Route.extend
  model: ->
    EmberMoney.IncomeOperation.find()

模板/addincome.handlebars

<div class="row container-bg"><br>
<div class="span6">
  <ul>
      {{#each operation in controller}}
        <li>{{operation.sum}}</li>
      {{/each}}
  </ul>
</div>
<div class="span6">
  {{outlet}}
</div>
</div>

// I want to render here more models! For example:

  <ul>
      {{#each income in incomes}}
        <li>{{income.name}}</li>
      {{/each}}
  </ul>
4

1 回答 1

1

未经测试,但在路线的 setupController 中,您可以:

# excuse the coffeescript...
setupController: (controller) ->
  controller.set('incomes', App.Income.find());

然后在您的模板中:

<ul>
  {{#each income in controller.incomes}}
    <li>{{income.name}}</li>
  {{/each}}

于 2013-03-24T11:25:00.373 回答