I have an array with JSON object:
{result" : "OK","data":[
{"name" : "henrytest",
"id" : "9a3d1faaaac742889a940a6d9df49d16"},
{"name" : "henrytest",
"id" : "9a3d1faaaac742889a940a6d9df49d16"},
{"name" : "henrytest",
"id" : "9a3d1faaaac742889a940a6d9df49d16"}
]
}
I'm trying to loop through the array to get the 3 fields displayed in my table. However nothing is getting diplayed. Here is my mustache template:
<table style="width:100%;">
<thead>
<tr>
<th>Name</th>
<th>User ID</th>
</tr>
</thead>
<tbody>
{{#data}}
<tr>
<td>{{name}}</td>
<td>{{id}}</td>
</tr>
{{/data}}
</tbody>
</table>
I'm not able to display any fields in the table.Stuck badly with this..:( :(Any ideas how i can achieve this??
dataproperty in JSO is an array. Are you sure that{{#data}}is accessing array elements one by one ? Most probably You'll need some sort of looping directive to loop through each element in the JSO. To test what I said, try replacing{{#data}}with{{#data[0]}}and see if you get the first element in the data array displayed correctly.