I am working on a project in which I am integrating WooCommerce APIs in the mobile application using AngualrJS.
Here is the API which returns a list of products, and this is the HTML page on which I am implementing AngualrJS.
The problem is I am unable to display multiple products on the HTML page.
HTML code:
<div ng-app="myApp" ng-controller="productCtrl">
<ul>
<li>hello</li>
<li ng:repeat="item in data">
{{item.id}} has children:
</li>
</ul>
</div>
JS file:
var app = angular.module('myApp', []);
app.controller('productCtrl', function($scope, $http) {
$http.get("http://www.ilexsquare.com/JwelTech/wordpress/api.php?function=GetProductsdetails")
.then(function (response) {$scope.data = response.data;});
});
and this is my jsfiddle code jsFiddle
Just change your ng-repeat
like this: <li ng-repeat="item in data.products">
Your products are under the key products
in your data
. See the working code below.
var app = angular.module('myApp', []);
app.controller('productCtrl', function($scope, $http) {
$http.get("http://www.ilexsquare.com/JwelTech/wordpress/api.php?function=GetProductsdetails")
.then(function(response) {
$scope.data = response.data;
});
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myApp" ng-controller="productCtrl">
<ul>
<li>hello</li>
<li ng-repeat="item in data.products">
{{item.id}}
</li>
</ul>
</div>
</div>