How do I bind the JSON data below, to an Html page using Mustache.js?
Data -
[
{
"procedureList": [
{
"procedureName": "Root Canal",
"cost": 10200
}
],
"department": "Dental"
},
{
"procedureList": [
{
"procedureName": "Vasactomy",
"cost": 10000
},
{
"procedureName": "IVF",
"cost": 10000
}
],
"department": "Gynic"
},
]
I tried the below solution,but it's creating data only for department 'Dental'.It's not looping through the entire Json array.
Any help in correcting the below template will be really appreciated
<div class="panel-group" id="accordion">
{{#department}} <!--array of department names-->
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne"><span class="glyphicon glyphicon-plus"></span> {{{department}}}</a>
</h4>
</div>
<div id="collapseOne" class="panel-collapse collapse">
<div class="panel-body">
{{#procedureList}} <!--array of procedure names-->
<div class="row">
<div class="col-md-6">
<p><a href="" target="_blank">{{procedureName}}</a></p>
</div>
<div class="col-md-6">
<button type = "button" class = "btn btn-primary">Starts from {{cost}}</button>
</div>
</div>
<p></p>
{{/procedureList}} <!--array of procedure names-->
</div>
</div>
</div>
{{/department}} <!--Array of department names-->
</div>