O'Reilly logo

Mastering Ember.js by Mitchel Kelonye

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Rendering enumerable data

Often, applications will need to display enumerable data that can be accomplished using the {{#each}} ... {{/each}} block expression. For example, our contacts template used this expression to display the list of contacts on the left as:

<ul class="nav nav-pills nav-stacked">
  {{#each model}}
  <li>
    ...{{name}}...
  </li>
  {{/each}}
</ul>

We left out the link-to expression, which we'll discuss shortly. The each block expression switches the working context on each iteration, as discussed in the previous section. If we don't wish to do so, we can specify the name of the current iteration object, as shown in the following reimplementation:

<ul class="nav nav-pills nav-stacked"> {{#each contact in model}} <li> ...{{contact.name}}... ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required