ejiqpep6
ejiqpep6

Reputation: 35

How to render multiply models in ember js

I have 3 models currency, income and income_operations. I wanna to render them on some route. What is the right way to do it? How can i render three models on one page?

UPD: This models don't have any associations between them.

route.js.coffee

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

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

templates/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>

Upvotes: 0

Views: 341

Answers (1)

Martin Stannard
Martin Stannard

Reputation: 811

Not tested, but in the route's setupController you could:

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

then in your template:

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

Upvotes: 1

Related Questions