I am learning Ember JS and Handlebars JS, so I am very new to this.
I am having a problem with a loop of nested JSON arrays. I can not scroll the "Pages" in JSON below.
Here is the JSON:
{
"Pages": [
{
"Id": 1,
"Name": "Page 1",
"Objects": [
{
"Width": 100,
"Height": 200,
"Type": "Shape"
},
{
"Width": 150,
"Height": 250,
"Type": "Image"
}
]
},
{
"Id": 2,
"Name": "Page 2",
"Objects": [
]
}
],
"Settings": {
"URL": "http://THEURL",
"Location": true,
"Navigation": true
},
"Id": 1,
"Title": "The Title",
"Description": "The Description"
}
This is my handlebars template:
<script type="text/x-handlebars" id="pages">
<div class="container">
<div class="row">
<h1>{{Title}}</h1>
<h2>{{Description}}</h2>
<ul>
{{#each Pages}}
<li>Page ID: {{Id}} <br /> Page Name: {{Name}} <br />
<ul>
{{#each Objects}}
<li>{{Type}}</li>
{{/each}}
</ul>
</li>
{{/each}}
</ul>
</div>
</div>
</script>
Also, when I just add:
{{Pages}}
in the descriptor template, the output in the browser:
[object Object],[object Object]
I am not sure if this is a problem or not.
source
share