<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<script type="text/javascript">
function fetchRecords($http){
$http.get("http://jsonplaceholder.typicode.com/posts")
.then(function (response) {
this.records = response.data})
}
function recordsCtrl($scope, list){
$scope.names = list.records
}
var newApp = angular.module('newApp',[])
newApp.service('list',fetchRecords)
newApp.controller('recordsCtrl',recordsCtrl)
</script>
</head>
<body ng-app="newApp" >
<div ng-controller="recordsCtrl">
<table>
<tr>
<th>Number</th>
<th>id</th>
<th>Title</th>
<th>Body</th>
</tr>
<tr ng-repeat='name in names' >
<td>{{name.userId}}</td>
<td >{{name.id}}</td>
<td >{{name.title}}</td>
<td >{{name.body}}</td>
</tr>
</table>
</div>
</body>
</html>
Impossible d'afficher les enregistrements qui sont en réponse, comment utiliser le service dans ANgular js, s'il vous plaît faites le moi savoir. J'essaie de garder le $ http dans le service personnalisé et à partir de là, je veux transmettre cette réponse à mon $ scope. quelqu'un peut m'aiderAngulaire 1, impossible d'afficher les enregistrements