1
votes

I'am testing Ember, and I see that {{each}} is deprecated now and I shouldu se {{each foo in bar}}.

In my code, when I use only {{each}} everything works fine.

<ul>
  {{#each}}
    <li>{{this.url}} - {{this.status}}</li>
  {{/each}}
</ul>

But, it log this message: Please use the keyword form ({{#each foo in bar}}) instead. See http://emberjs.com/guides/deprecations/#toc_more-consistent-handlebars-scope for more details.

So, I updated my code to:

<ul>
  {{#each b in billing}}
    <li>{{b.url}} - {{b.status}}</li>
  {{/each}}
</ul>

And seems that billing is empty or something like that.

My Model:

import DS from 'ember-data';

// billing.js
export default DS.Model.extend({
  status: DS.attr('string'),
  url: DS.attr('string')
});

My Routes:

import Ember from 'ember';

export default Ember.Route.extend({
        model: function() {
                return this.store.find('billing');
        }
});

Ember console: http://prntscr.com/6ibgfh

Thanks

2

2 Answers

3
votes

The issue is that the each helper doesn't know what billing is.

{{#each b in billing}}

Should be:

{{#each b in model}}

0
votes

There is also a new "block param" syntax, so that if you have a model defined as follows:

App.IndexRoute = Ember.Route.extend({
  model: function() {
    return { notes: ['red', 'yellow', 'blue'] };
  }
});

You can loop through it as follows:

{{#each notes as |note| }}
  {{ note }}
{{/each}} 

Working example here