Bir litlle programm açısal olarak yazarım. URL'ye gittiğimde: http://localhost:8080/api/v1/projects (bir istek isteği), tarayıcıda bir json tablosu görüyorum. Yapmak istediğim şey, bu nesnelerin bir "listesinin" olmasıdır. Ben sadece json için değil, kullanıcılara sunulabilir bir şey demek istiyorum.ng-tıklama açısal olarak nasıl kullanılır
bunlar benim dosyalar şunlardır:
var app = angular.module('app');
app.service('apiService', ['$http', function($http) {
this.get = function() {
return $http.get("http://localhost:8080/api/v1/projects");
};
this.delete = function(id) {
return $http.delete("http://localhost:8080/api/v1/projects/{id}", id);
}
this.post = function(data){
return $http.post("http://localhost:8080/api/v1/projects", data);
}
}]);
index.js
service.js
index.html index.js ve service.js
app.controller('controller', ['$scope', 'apiService', function($scope, apiService) {
var vm = this;
var getData = apiService.get().success(function(data) {
vm.data = data;
});
}]);
index.html
<!DOCTYPE html>
<html lang="en" ng-app="myApp">
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javavscript" src="angular.min.js"></script>
<script type="text/javavscript" src="index.js"></script>
<script type="text/javavscript" src="service.js"></script>
</head>
<body>
<div ng-controller="controller as ctrl">
<div ng-repeat="data in ctrl.data">{{data.name}}</div>
</div>
</body></html>
ben ng tıklayın (veya sonucunu göstermek için herhangi bir yöntem) Ben yerine URL'min giderseniz belgelerin listesi var benim kodunda içerebilir sadece nasıl olduğunu söyleyebilir json
'un bir listesini görmek Teşekkür ederim!