我有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>
答案 0 :(得分:1)
未经测试,但在路线的setupController中你可以:
# excuse the coffeescript...
setupController: (controller) ->
controller.set('incomes', App.Income.find());
然后在你的模板中:
<ul>
{{#each income in controller.incomes}}
<li>{{income.name}}</li>
{{/each}}