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 Challenge 1: Loading Arrays

Agustin Grube
Agustin Grube
39,278 Points

Problem with Ember.js Models Challenge.

Is there something wrong with this challenge? I can pass part one, but when I do part two with my code, it says part one in mo longer parsing.

js/app.js
AnimalShelter = Ember.Application.create();

AnimalShelter.Router.map(function() {
  this.resource('kittens', {path: '/'});
});

var kittens = [
  {id: '1', name: 'Meowzer'},
  {id: '2', name: 'Squeaky'},
  {id: '3', name: 'Fluffy'}
]

AnimalShelter.KittensRoute = Ember.Route.extend({
  controllerName: 'kittens',
  renderTemplate: function(){
    this.render('kittens');
  },
  model: function(){
    return kittens;
  }
});
index.html
<!DOCTYPE html>
<html>
<head>
  <title>Animal Shelter</title>
</head>
<body>
  <script src="js/libs/jquery-1.10.2.js"></script>
  <script src="js/libs/handlebars-v1.3.0.js"></script>
  <script src="js/libs/ember-1.8.1.js"></script>
  <script src="js/app.js"></script>

  <script type="text/x-handlebars" id="kittens">
    <h1>Kittens</h1>
    <p>Here is a list of all of our kittens:</p>
    <ul>
        {{#each post in model}}
            <li>{{#link-to 'post' post.id}}{{post.title}}{{/link-to}}</a></li>
        {{/each}}
    </ul>
  </script>

</body>
</html>

1 Answer

Roberto Alicata
PLUS
Roberto Alicata
Courses Plus Student 39,959 Points

The #each loop is wrong

<!DOCTYPE html>
<html>
<head>
  <title>Animal Shelter</title>
</head>
<body>
  <script src="js/libs/jquery-1.10.2.js"></script>
  <script src="js/libs/handlebars-v1.3.0.js"></script>
  <script src="js/libs/ember-1.8.1.js"></script>
  <script src="js/app.js"></script>

  <script type="text/x-handlebars" id="kittens">
    <h1>Kittens</h1>
    <p>Here is a list of all of our kittens:</p>
    <ul>
        {{#each}}
            <li>{{name}}</li>
        {{/each}}
    </ul>
  </script>

</body>
</html>