我从 AngularJS 开始,我需要使用它来使用 REST 服务。为什么这个 GET 调用不起作用?
控制器.js
angular.module("myApp", []);
function GetController($scope) {
$scope.click = function() {
// $http.defaults.useXDomain = true;
var response = $http.get('http://localhost:8080/ticketsales/pruebas');
response.success(function(data, status, headers, config) {
alert("Ok.");
});
response.error(function(data, status, headers, config) {
alert("Error.");
});
};
}
索引.html
<div ng-controller="GetController">
<button ng-click="click()">Click me</button>
</div>