Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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}}