ember.js - ember.js - Ember {{#each}} helper not rendering - answerstu - answerstu.com answerstu

ember.js - Ember {{#each}} helper not rendering

I am fairly new to web development and I was trying to walk through the ember doc examples. Everything was working ok until I tried to use the {{#each}} helper. I don't see what I am doing wrong, am I using the right version of handlebars?

Here is inside my html:

<div>First element</div>
<div id="second-placeholder"></div>
<div>Third element</div>

<script type="text/x-handlebars" data-template-name="second-item-template">
    {{#each App.egosController}}
        <h3>{{name}}</h3>
        <p>{{id}} - {{type}}</p>
    {{/each}}
</script>

And here is my controller:

App.egosController = Ember.ArrayController.create({
    content: [],
    init: function(){
        alert('Controller Initialised!');
    }
});

App.egosController.set('content', [ego, alterEgo]);

Ember.View.create({
    templateName: 'second-item-template'
}).appendTo('#second-placeholder');

jsfiddle here: http://jsfiddle.net/VqgMk/64/

Thanks,

Ren

2 Answers

  1. Phoebe- Reply

    2019-11-15

    The variable ego is not defined. Just replace ego with myEgo and it should work.

  2. Quentin- Reply

    2019-11-15

    As louiscoquio pointed out, my ego variable was not initialised. I guess I'll use the console next time.

Leave a Reply

Your email address will not be published. Required fields are marked *

You can use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>