Bonjour tout le monde,
Voilà je développe une application avec Spring Boot utilisant les @RestController.
Maintenant j'utilise Angular coté client pour effectuer certaines taches. Mon soucis en est que quand j'exécute une fonction pour afficher les données au niveau de mon navigateur, je ne vois rien s'afficher dans mon tableau et pourtant si j'essaie d'inspecter le code je vois belle et bien que la fonction répond favorablement sans erreurs.
Voici mon controller :
Et voilà là ou il doit fonctionner :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 var application = angular.module('Greensoft', ['ui.router']); application.controller('GreenController', function($scope,$http) { $scope.pageProduits = []; $scope.motcle = ''; $scope.pagecourante = 0; $scope.size = 5; $scope.pages = []; $scope.Chercherproduits = function(){ $http.get("http://localhost:8080/checherProduits/"+$scope.motcle+"?page="+$scope.pagecourante+"&size="+$scope.size) .success(function(data){ $scope.pageProduits = data; $scope.pages = new array(data.totalPages); }) .error(function(error){ console.log(error); }); }; $scope.goToPage = function(page){ $scope.pagecourante = page; $scope.Chercherproduits(); }; $scope.GetProduits = function(){ $scope.pagecourante = 0; $scope.Chercherproduits(); }; });
Code html : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 <div data-ng-app="Greensoft" data-ng-controller="GreenController"> <div class="container" style="margin-top: 120px; margin-bottom: 25px"> <div class="form-group"> <input type="text" name = "motcle" data-ng-model="motcle" class="form-control" required="required" /> </div> <button class="btn btn-primary" data-ng-click="GetProduits()">Chercher</button> </div> <strong>{{motcle}}</strong> <div class="container"> <table class="table table-bordered table-condensed table-hover"> <thead> <tr class="text-success"> <th>Identifiant</th> <th>Désignation</th> <th>Description</th> <th>Prix Produit</th> <th>Quantité</th> </tr> </thead> <tbody> <tr data-ng-repeat="p in pageProduits.content"> <td>{{p.idProduit}}</td> <td>{{p.designation}}</td> <td>{{p.descriptions}}</td> <td>{{p.prix}}</td> <td>{{p.quantite}}</td> </tr> </tbody> </table> </div> <div class="container"> <ul class="pagination"> <li data-ng-class="{active:$index==pagecourante}" data-ng-repeat="page in pages track by $index"> <a data-ng-click="goToPage($index)" >{{$index}}</a> </li> </ul> </div> </div> Merci pour votre aide!
Partager