The JSON provided below is being utilized It comprises an array of objects (branch) with sub-objects called "service". The goal is to display the branch name and its services, specifically those categorized as cream.
[
{
"b_sn": "1",
"b_name": "Alambagh",
"service": [
{
"i_sn": "1",
"i_name": "Vanilla",
"i_type": "cream",
"i_detail": ""
},
{
"i_sn": "2",
"i_name": "Orange",
"i_type": "candy",
"i_detail": ""
}
]
},
{
"b_sn": "2",
"b_name": "Aminabad",
"service": [
{
"i_sn": "3",
"i_name": "Butterscotch",
"i_type": "cream",
"i_detail": ""
},
{
"i_sn": "4",
"i_name": "Blueberry",
"i_type": "cream",
"i_detail": ""
}
]
},
{
"b_sn": "3",
"b_name": "Hazratganj",
"service": [
{
"i_sn": "1",
"i_name": "Orange",
"i_type": "candy",
"i_detail": ""
},
{
"i_sn": "2",
"i_name": "Mango",
"i_type": "candy",
"i_detail": ""
}
]
}
]
The objective is to exhibit only the rows where i_type ="cream"
. If a branch (object) does not contain any sub-object labeled "cream", then its b_name
should be excluded from the table.
Below is the HTML code snippet from the page:
<table>
<tr>
<th>SN.</th>
<th>Branch Name</th>
<th>Services</th>
</tr>
<tr data-ng-repeat="br in branches">
<td>{{br.b_sn}}.</td>
<td>{{br.b_name}}</td>
<td>
<table>
<th></th>
<tr data-ng-repeat="i in br.service">
<td style="width:70%">{{i.i_sn}}. {{i.i_name}}</td>
<td>{{i.detail}}</td>
</tr>
</table>
</td>
</tr>
</table>