I have a problem when i want to show some records from my databse in html page : i have an empty array in html page. I have a restful service that shows my json data : http://localhost:8080/produits
[{"id":1,"designation":"HP CDG","prix":123.0,"quantite":456},{"id":2,"designation":"Samsung galaxy","prix":905.0,"quantite":7}]
I am using spring boot application
the javascript file : app.js
var app = angular.module("MyApp",[])
app.controller("ProduitController",function($scope,$http){
$scope.produits=null;
$http.get("http://localhost:8080/produits")
.success(function(data){
$scope.produits=data;
})
.error(function(err){
console.log(err);
})
});
my index.html page :
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
<title>catalogue</title>
<script type="text/javascript" src="angular/angular.min.js"></script>
<script type="text/javascript" src="js/app.js"></script>
</head>
<body ng-app="MyApp" ng-controller="ProduitController">
<h3>Test</h3>
<div class="Container">
<table>
<tr>
<th>ID</th>
<th>Designation</th>
<th>Prix</th>
<th>Quantite</th>
</tr>
<tr ng-repeat="p in produits">
<td>{{p.id}}</td>
<td>{{p.designation}}</td>
<td>{{p.prix}}</td>
<td>{{p.quantite}}</td>
</tr>
</table>
</div>
</body>
</html>