[英]Handlebars access to nested properties
im trying to use handlebars to print a list i'm getting from a json. 我试图使用车把来打印我从json得到的列表。 The data structure is complex (to me) so i cant seem to get to the nested property i need. 数据结构(对我而言)很复杂,因此我似乎无法获得所需的嵌套属性。
The data looks like this: 数据如下所示:
var data = [{ var数据= [{
"response": { “响应”:{
"status": "ok", “ status”:“确定”,
"indexes": { “索引”:{
"child": [ { "isDir": false, "contentType": "video/avi", "suffix": "avi", }, { "isDir": false, "contentType": "video/avi", "suffix": "avi", } ], "index": [ { "name": "A", "dataIneed": [ { "id": 291, "name": "Example1" }, { "id": 292, "name": "Example2" }, { "id": 293, "name": "Example3" }, ] } ], "lastModified": 1385842880050 }, "xmlns": "http://example.org/restapi", "version": "123" }}]`
In a table i want to print: - Example1 - Example2 - Example3 在表格中我要打印:-Example1-Example2-Example3
my html / handlebars looks like this: 我的html /把手看起来像这样:
<table class="table">
{{#each }}
<tr><td>
{{response.indexes.index.0.dataIneed.0.name}}
</td></tr>
{{/each}}
</table>
And is able to print: - Example1 并能够打印:-Example1
How do i loop get the result i want? 我如何循环获得我想要的结果?
Thanks for the help! 谢谢您的帮助!
Best regards, e 最好的问候
You have to specify where to loop 您必须指定在哪里循环
<table class="table">
{{#each esponse.indexes.index.0.dataIneed}}
<tr><td>
{{this.name}}
</td></tr>
{{/each}}
</table>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.