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
The variable
egois not defined. Just replaceegowithmyEgoand it should work.