I am using a PHP script to get values from database. This is the json result obtained from the PHP script.
{"subcategories":
[
{"category":"Grocery",
"products":
[
{"name":"Mixture"},
{"name":"Chocolates"},
{"name":"Noodles"}
]
},
{"category":"Evening Strolls",
"products":
[
{"name":"Shawarma"},
{"name":"Momos"},
{"name":"Sandwiches"},
{"name":"Sizzling Kebabs"},
{"name":"Desi Delights"}
]
}
]
}
This is my App and controller.
var app = angular.module('myApp', []);
app.controller('customersCtrl', function ($scope, $http) {
$http.get("testing.php")
.then(function (response)
{
$scope.result = response.data.subcategories;
});
});
This is the HTML code
<div class="w3-row">
<div ng-repeat="x in result" class="w3-col s12 m12 l12">
<table>
<tr>
<td>
<h3>{{ x.category }}</h3>
</td>
<td>
<h3 style="font-family:'Droid Sans'" id="title_cat"></h3>
</td>
</tr>
</table>
<div id="sub" class="w3-row">
<div ng-repeat="y in x.products" class="w3-col s4 m4 l4">
<table>
<tr>
<td>
<p>{{ y.name }}
<br />
</p>
</td>
</tr>
<tr>
<td>
<h3 style="font-family:'Droid Sans';text-align:center" id="title_cat">{{ y.name }}</h3>
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
I want to display categories and then the array of products. What should i do?