Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Ember.js Models Loading Arrays of JavaScript objects

How do rewrite the model part of this tutorial so i stop having this depreciation warning in the console?

"DEPRECATION: Using the context switching form of {{each}} is deprecated. Please use the keyword form ({{#each foo in bar}}) instead. See http://emberjs.com/guides/deprecations/#toc_more-consistent-handlebars-scope for more details."

My problem is how do i make the model avilable in the view with variable name other than model because i don't think it's good pratice to have {{#each post in model }} or {{#each comment in model }} i would like to use comments and postsinstead of model?

Michael Dvorscak
Michael Dvorscak
7,003 Points

You can use either:

{{#each model as |post|}}
<!-- OR -->
{{#each post in model}}

From what I've read it doesn't look like it's possible to alias the model. This is an example of convention over configuration. (Please let me know if I'm wrong, since I also prefer the comment in post syntax)

Andre Kovac
Andre Kovac
5,588 Points

Thanks Michael Dvorscak and exuper okouya for the hints. I got it working with model with Ember 1.9.0. I see that this probably is an example of convention over configuration but still wonder why the examples in the Ember Deprication List give examples like:

{{#each person in people}}
  <p>{{person.firstName}} {{person.lastName}}</p>
  <p>{{person.address}}</p>
{{/each}}

Can someone clarify why

{{#each post in posts}}

won't work in our Dracula app?

1 Answer

Carmine Maraglio
Carmine Maraglio
29,762 Points

I was able to get this working in 1.10 using:

{{#each post in model}}
   <li>{{post.title}}</li>
{{/each}}