So, I have this web app in which I am using hbs as the templating engine. Now, from my rest API I am sending over an array of JSON objects:
[{";_id":"5704630a7d4cd367f8dsdce7","name":"Seagate","description":"This awesome Hard disk" ,"categories":["SDD","256GB"]}]
I have a variable: disklist, that has this data.
Using handlebars this is what I have tried so far, but it does not seem to work.
console.log(disklist[0].name); // LOGS THE NAME PROPERLY
var source = $("#dlist").html();
var template = Handlebars.compile(source);
var wrapper = {objects: disklist};
In html:
<script type='text/template' id='dlist'>
<li>
{{#each objects}}
<h1>{{name}}</h1>
{{/each}}
</li>
</script>
But nothing prints!
How do I fix this?
Also, if there is a way to do this with just bare-bones JavaScript, please do share!